From cc80fa1aa50db53ea22bf11b8a4116908035c125 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 17 Feb 2016 14:03:00 -0800 Subject: [PATCH] fix for unicorn usr2 signal handling --- config/unicorn/production.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/unicorn/production.rb b/config/unicorn/production.rb index 17ced544f..427d92757 100644 --- a/config/unicorn/production.rb +++ b/config/unicorn/production.rb @@ -24,18 +24,18 @@ stdout_path "/dev/null" # Set master PID location pid "#{app_path}/tmp/pids/unicorn.pid" -# before_fork do |server, worker| -# ActiveRecord::Base.connection.disconnect! +before_fork do |server, worker| + ActiveRecord::Base.connection.disconnect! -# old_pid = "#{server.config[:pid]}.oldbin" -# if File.exists?(old_pid) && server.pid != old_pid -# begin -# Process.kill("QUIT", File.read(old_pid).to_i) -# rescue Errno::ENOENT, Errno::ESRCH -# # someone else did our job for us -# end -# end -# end + old_pid = "#{server.config[:pid]}.oldbin" + if File.exists?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + # someone else did our job for us + end + end +end # after_fork do |server, worker| # ActiveRecord::Base.establish_connection