Skip to content

Instantly share code, notes, and snippets.

@hideack
Last active June 20, 2020 04:48
Show Gist options
  • Select an option

  • Save hideack/c9ecf1c91f5c5f482ae261b6c8d846aa to your computer and use it in GitHub Desktop.

Select an option

Save hideack/c9ecf1c91f5c5f482ae261b6c8d846aa to your computer and use it in GitHub Desktop.
before_fork do |server, worker|
ENV['BUNDLE_GEMFILE'] = "#{pj_root_dir}/current/Gemfile"
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade. The last worker spawned
# # will then kill off the old master process with a SIGQUIT.
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment