Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicorn restart/upgrade doesn't work

Tags:

unicorn

Following is link to my init script for unicorn. https://gist.github.com/1466775

Restart command has never worked for me. I am using upgrade to restart unicorn after each deploy. But whenever there is major changes like new gems being added, upgrade won't work. Recently, i replaced hoptoad gem with airbrake and it errors out saying 'uninitialized constant Airbrake (NameError)'. But when i stopped and started unicorn again, it worked fine. Does the problem lies in init script or its different problem?

Thanks.

like image 776
bikashp Avatar asked Dec 12 '11 11:12

bikashp


1 Answers

According to your init script, "/bin/init.d/unicorn restart" sends HUP signal to unicorn master process

------cropped

restart|reload)
    sig HUP && echo reloaded OK && exit 0
    echo >&2 "Couldn't reload, starting '$CMD' instead"
    su - $USER -c "$CMD"

-----cropped

This is what HUP does to unicorn process :

reloads config file and gracefully restart all workers. If the “preload_app” directive is false (the default), then workers will also pick up any application code changes when restarted. If “preload_app” is true, then application code changes will have no effect.

What you are looking for is USR2 signal which your upgrade parameter to unicorn is already doing !

USR2 signal re-executes the running binary. A separate QUIT should be sent to the original process once the child is verified to be up and running.

like image 195
kaji Avatar answered Jan 04 '23 13:01

kaji