Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicorn failing to spawn workers on USR2 signal

I'm sending a USR2 signal to the master process in order to achieve zero downtime deploy with unicorn. After the old master is dead, I'm getting the following error:

adding listener failed addr=/path/to/unix_socket (in use)

unicorn-4.3.1/lib/unicorn/socket_helper.rb:140:in `initialize':
Address already in use - /path/to/unix_socket (Errno::EADDRINUSE)

The old master is killed in the before_fork block on the unicorn.rb config file. The process is started via upstart without the daemon (-D) option. Any Ideia on what's going on?

like image 889
marcosbeirigo Avatar asked Dec 11 '12 16:12

marcosbeirigo


1 Answers

Well, turns out you have to run in daemonized mode (-D) if you want to be able to do zero downtime deployment. I changed a few things in my upstart script and now it works fine:

setuid username
pre-start exec unicorn_rails -E production -c /path/to/app/config/unicorn.rb -D
post-stop exec kill cat `/path/to/app/tmp/pids/unicorn.pid`
respawn
like image 62
marcosbeirigo Avatar answered Oct 26 '22 21:10

marcosbeirigo