Methods
G
K
N
P
R
U
Class Public methods
graceful(pid)

Forces the (rails) application to gracefully terminate by sending a TERM signal to the process.

# File rails/railties/lib/commands/process/reaper.rb, line 32
def graceful(pid)
  %xkill -s TERM #{pid}`
end
kill(pid)

Forces the (rails) application to terminate immediately by sending a -9 signal to the process.

# File rails/railties/lib/commands/process/reaper.rb, line 38
def kill(pid)
  %xkill -9 #{pid}`
end
new(pid_path, pattern, keyword=nil)
# File rails/railties/lib/commands/process/reaper.rb, line 48
def initialize(pid_path, pattern, keyword=nil)
  @pid_path, @pattern, @keyword = pid_path, pattern, keyword
end
process(action, pid_path, pattern, keyword)

Searches for all processes matching the given keywords, and then invokes a specific action on each of them. This is useful for (e.g.) reloading a set of processes:

Killer.process(:reload, "/tmp/pids", "dispatcher.*.pid")
# File rails/railties/lib/commands/process/reaper.rb, line 14
def process(action, pid_path, pattern, keyword)
  new(pid_path, pattern, keyword).process(action)
end
reload(pid)

Forces the (rails) application to reload by sending a HUP signal to the process.

# File rails/railties/lib/commands/process/reaper.rb, line 20
def reload(pid)
  %xkill -s HUP #{pid}`
end
restart(pid)

Force the (rails) application to restart by sending a USR2 signal to the process.

# File rails/railties/lib/commands/process/reaper.rb, line 26
def restart(pid)
  %xkill -s USR2 #{pid}`
end
usr1(pid)

Send a USR1 signal to the process.

# File rails/railties/lib/commands/process/reaper.rb, line 43
def usr1(pid)
  %xkill -s USR1 #{pid}`
end
Instance Public methods
process(action)
# File rails/railties/lib/commands/process/reaper.rb, line 52
def process(action)
  pids = find_processes

  if pids.empty?
    warn "Couldn't find any pid file in '#{@pid_path}' matching '#{@pattern}'"
    warn "(also looked for processes matching #{@keyword.inspect})" if @keyword
  else
    pids.each do |pid|
      puts "#{action.capitalize}ing #{pid}"
      self.class.send(action, pid)
    end
    
    delete_pid_files if terminating?(action)
  end      
end