Class: Server::Starter::ResqueListener
- Inherits:
-
Object
- Object
- Server::Starter::ResqueListener
- Defined in:
- lib/server/starter/resque_listener.rb
Class Method Summary collapse
-
.graceful_restart(starter, worker, worker_nr, status_file) ⇒ Object
This allows a new master process to incrementally phase out the old master process with SIGTTOU.
Class Method Details
.graceful_restart(starter, worker, worker_nr, status_file) ⇒ Object
This allows a new master process to incrementally phase out the old master process with SIGTTOU. The last worker spawned will then kill off the old master process with a SIGQUIT.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/server/starter/resque_listener.rb', line 14 def self.graceful_restart(starter, worker, worker_nr, status_file) pids = File.readlines(status_file).map {|_| _.chomp.split(':') }.to_h old_gen = ENV['SERVER_STARTER_GENERATION'].to_i - 1 if old_pid = pids[old_gen.to_s] sig = (worker_nr + 1) >= starter.num_workers ? :QUIT : :TTOU Process.kill(sig, old_pid.to_i) end rescue Errno::ENOENT, Errno::ESRCH => e $stderr.puts "#{e.class} #{e.}" end |