Simple Capistrano Unicorn
Contains a namespace with methods for administrating the unicorn server through capistrano recipes.
This gem is composed from the gems capistrano-unicorn-methods and capistrano-unicorn. It is roughly the structure of capistrano-unicorn-methods with clever ideas from capistrano-unicorn.
Setup
1. Add Gem to Gemfile
gem 'simple-capistrano-unicorn'2. Require this gem
You should add this line to your Capfile:
require 'capistrano/simple-capistrano-unicorn'3. Restart Unicorn on deploy
You should place this line in PROJECT_ROOT/config/deploy.rb:
after 'deploy', 'unicorn:restart'4. Add your unicorn.rb
Grab the sample Unicorn configuration here: https://github.com/kaspergrubbe/simple-capistrano-unicorn/blob/master/configs/unicorn.conf.rb
And place it here: PROJECT_ROOT/config/unicorn.rb change the app_dir variable to suit your configuration.
Usage
Go through the setup and run: cap production deploy
The gem gives you access to the following tasks:
-
unicorn:startstarts the Unicorn processes -
unicorn:stopstops the Unicorn processes -
unicorn:restartmakes a seamless zero-downtime restart -
unicorn:hard_restartbasically runsunicorn:stopfollowed with aunicorn:start
Requirements
unicorncapistrano
Customization
You can customize the gems behavior by setting any (or all) of the following options within capistrano's configuration:
-
unicorn_pidindicates the path for the pid file. Defaults to"#{shared_path}/tmp/pids/unicorn.pid". -
unicorn_old_pidindicates the path for the old pid file, which Unicorn creates when forking a new master. Defaults to#{shared_path}/tmp/pids/unicorn.pid.oldbin. -
unicorn_configthe path to the unicorn config file. Defaults to"#{current_path}/config/unicorn.rb". -
unicorn_logthe path where unicorn places its STDERR-log. Defaults to"#{shared_path}/log/unicorn.stderr.log". -
rack_envsets the environment that the server will run in. Defaults to"production".