do |server, worker | # there's no need for the master process to hold a connectio n if defined?(ActiveRecord::Base ) ActiveRecord::Base.connection.disconnect ! en d # Before forking, kill the master process that belongs to the .oldbin PID . # This enables 0 downtime deploys . old_pid = "#{server.config[:pid]}.oldbin " if File.exist?(old_pid) && server.pid != old_pi d begi n Process.kill("QUIT", File.read(old_pid).to_i ) rescue Errno::ENOENT, Errno::ESRC H # someone else did our job for u s en d en d end
Rails app during the before_con fi guration callback, which is fi red when the Application constant is de fi ned in con fi g/application.rb • unicorn-worker-killer • Automatically restart Unicorn workers based on 1) max number of requests and 2) max memory