add unicorn logic to cap
This commit is contained in:
@@ -23,3 +23,25 @@ stdout_path "log/unicorn.log"
|
||||
|
||||
# Set master PID location
|
||||
pid "#{app_path}/tmp/pids/unicorn.pid"
|
||||
|
||||
before_fork do |server, worker|
|
||||
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
|
||||
|
||||
if defined?(ActiveRecord::Base)
|
||||
ActiveRecord::Base.connection.disconnect!
|
||||
end
|
||||
end
|
||||
|
||||
after_fork do |server, worker|
|
||||
if defined?(ActiveRecord::Base)
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user