Leave a comment

Capistrano deployment for Rails

I think I have found my all time favorite gem; capistrano-unicorn

Simply put, if you use Capistrano and Unicorn, you have to use this gem.  I have messed around with setting up init.d scripts for starting and stopping Unicorn and they have all been more trouble than help.

All I had to do was add a couple of lines to my deploy.rb file:

# Unicorn tasks
require 'capistrano-unicorn'
after 'deploy:restart', 'unicorn:reload'
after 'deploy:restart', 'unicorn:restart'

I think that the best thing about this gem is the added cap tasks that can be run from your machine:

cap unicorn:add_worker               # Add a new worker
cap unicorn:remove_worker            # Remove amount of workers
cap unicorn:reload                   # Reload Unicorn
cap unicorn:restart                  # Restart Unicorn
cap unicorn:show_vars                # Debug Unicorn variables
cap unicorn:shutdown                 # Immediately shutdown Unicorn
cap unicorn:start                    # Start Unicorn master process
cap unicorn:stop                     # Stop Unicorn

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: