Class: Brindle::Restart

Inherits:
Object
  • Object
show all
Includes:
GoldenBrindle::Command::Base
Defined in:
lib/golden_brindle/restart.rb

Instance Attribute Summary

Attributes included from GoldenBrindle::Command::Base

#done_validating, #original_args, #valid

Instance Method Summary collapse

Methods included from GoldenBrindle::Command::Base

#can_change_user?, #config_keys, #failure, #help, #initialize, #load_config, #options, #valid?, #valid_dir?, #valid_exists?, #valid_file?, #valid_group?, #valid_user?

Instance Method Details

#configureObject



6
7
8
9
10
11
12
13
# File 'lib/golden_brindle/restart.rb', line 6

def configure 
  options [ 
    ['-c', '--chdir PATH', "Change to dir before starting (will be expanded).", :@cwd, "."],
    ['-C', '--config PATH', "Use a mongrel based config file", :@config_file, nil],
    ['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false],
    ['-P', '--pid FILE', "Where the PID file is located.", :@pid_file, "tmp/pids/unicorn.pid"]
  ]
end

#runObject



30
31
32
33
34
35
36
# File 'lib/golden_brindle/restart.rb', line 30

def run
  if @soft
    GoldenBrindle::send_signal("HUP", File.join(@cwd,@pid_file))
  else
    GoldenBrindle::send_signal("USR2", File.join(@cwd,@pid_file))
  end
end

#validateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/golden_brindle/restart.rb', line 15

def validate
  if @config_file
    valid_exists?(@config_file, "Config file not there: #@config_file")
    return false unless @valid
    @config_file = File.expand_path(@config_file)
    load_config
    return false unless @valid
  end
  
  @cwd = File.expand_path(@cwd)
  valid_dir? @cwd, "Invalid path to application dir: #@cwd"
  valid_exists? File.join(@cwd,@pid_file), "PID file #@pid_file does not exist.  Not running?"
  @valid
end