Strange quit behavior

Alex Sharp ajsharp at gmail.com
Tue Aug 2 19:49:11 EDT 2011


On Tue, Aug 2, 2011 at 4:08 PM, Eric Wong <normalperson at yhbt.net> wrote:
> James Cox <james at imaj.es> wrote:
>> So what should that look like? all but that nr-workers stuff? can i
>> just remove the before fork? and what would you say is a super good
>> unicorn config to start from?
>
> Yeah, skip the before_fork and also after_fork.  Those are mainly for
> disconnect/reconnect of ActiveRecord and anything else that might need a
> network connection.

FWIW, we use the before_fork hook to automatically kill the old master
by sending it QUIT:

before_fork do |server, worker|
  old_pid = '/var/www/api/shared/pids/unicorn.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
      # another newly forked workers has already killed it
    end
  end
end

- alex


More information about the mongrel-unicorn mailing list