Capistrano plugin that integrates Unicorn tasks into capistrano deployment script.
Install library from rubygems:
gem install capistrano-unicorn
Add the library to your Gemfile
:
group :development do
gem 'capistrano-unicorn', :require => false
end
And load it into your deployment script config/deploy.rb
:
require 'capistrano-unicorn'
Add unicorn restart task hook:
after 'deploy:restart', 'unicorn:reload' # app IS NOT preloaded
after 'deploy:restart', 'unicorn:restart' # app preloaded
Create a new configuration file config/unicorn/unicorn.rb
or config/unicorn/STAGE.rb
, where stage is your deployment environment.
Example config - examples/rails3.rb. Please refer to unicorn documentation for more examples and configuration options.
First, make sure you're running the latest release:
cap deploy
Then you can test each individual task:
cap unicorn:start
cap unicorn:stop
cap unicorn:reload
You can modify any of the following options in your deploy.rb
config.
unicorn_env
- Set unicorn environment. Default torails_env
variable.unicorn_pid
- Set unicorn PID file path. Default tocurrent_path/tmp/pids/unicorn.pid
unicorn_bin
- Set unicorn executable file. Default tounicorn
.unicorn_bundle
- Set bundler command for unicorn. Default tobundle
.unicorn_user
- Launch unicorn master as the specified user. Default touser
variable.unicorn_roles
- Define which roles to perform unicorn recpies on. Default to:app
.unicorn_config_path
- Set the directory where unicorn config files reside. Default tocurrent_path/config
.unicorn_config_filename
- Set the filename of the unicorn config file. Not used in multistage installations. Default tounicorn.rb
.unicorn_task_options
- Set unicorn task options. Default to:except => {:no_release => true}
.
If you are using capistrano multistage, please refer to Using capistrano unicorn with multistage environment.
To get a list of all capistrano tasks, run cap -T
:
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:shutdown # Immediately shutdown Unicorn
cap unicorn:start # Start Unicorn master process
cap unicorn:stop # Stop Unicorn
See LICENSE file for details.