Leave a comment

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”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: