Making Unicorn behave....

This one had me going for a bit so I figured that I would share my solution.....

I am using git-deploy for one of my clients for their two servers.  It is quite similar to Capistrano but I like it better.

The git-deploy uses 3 files for deployment; after_push, before_restart, and restart.  I needed to restart Unicorn after deployments but found that I could not do so without using sudo and the password for the user.  This didn't work in the "restart" file so I found myself manually restarting Unicorn after every deploy.  Pain in the ass......

First run "visudo" from the server command line.  It may require using sudo first.  Then I added:

<server_name> ALL=NOPASSWD: /etc/init.d/unicorn restart, /etc/init.d/unicorn stop, /etc/init.d/unicorn start

This gave the <server_user> the privilege to run sudo  /etc/init.d/unicorn restart without having to enter the password.

So I just needed to add run "sudo /etc/init.d/unicorn restart" to the git-deploy "restart file"

comments powered by Disqus