This is a capistrano v3 plugin that integrates Unicorn tasks into capistrano deployment scripts; it was heavily inspired by sosedoff/capistrano-unicorn but written from scratch to use the capistrano 3 syntax.
-
The
unicorn:starttask invokes unicorn asbundle exec unicorn. -
When running tasks not during a full deployment, you may need to run the
rvm:hook:cap production rvm:hook unicorn:start
You can override the defaults by set :unicorn_example, value in the config/deploy.rb or config/deploy/ENVIRONMENT.rb capistrano deployment files
-
:unicorn_pidAssumes your pid file will be located in
tmp/pids/unicorn.pidwhich is symlinked by:linked_dirsto survive across deploymentsNOTE: THIS PATH WAS CHANGED AS OF v0.1.0
-
:unicorn_config_pathAssumes that your Unicorn configuration will be located in
config/unicorn/RAILS_ENV.rb -
:unicorn_restart_sleep_timeWhen performing zero-downtime deployment via the
unicorn:restarttask, send the USR2 signal, sleep for this many seconds (defaults to 3), then send the QUIT signal -
:unicorn_rolesRoles to run unicorn commands on. Defaults to :app
-
:unicorn_optionsSet any additional options to be passed to unicorn on startup. Defaults to none
-
:unicorn_rack_envSet the RACK_ENV. Defaults to deployment unless the RAILS_ENV is development. Valid options are "development", "deployment", or "none". See the RACK ENVIRONMENT section of the unicorn documentation for more information.
-
:unicorn_bundle_gemfileSets the BUNDLE_GEMFILE so that unicorn will point at the new Gemfile after unicorn:restart. Defaults to
current/Gemfile.
Add the library to your Gemfile:
group :development do
gem 'capistrano3-unicorn'
endAdd the library to your Capfile:
require 'capistrano3/unicorn'Invoke Unicorn from your config/deploy.rb or config/deploy/ENVIRONMENT.rb:
If preload_app:true use:
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
invoke 'unicorn:restart'
end
endOtherwise use:
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
invoke 'unicorn:reload'
end
endNote that presently you must put the invoke outside any on block since the task handles this for you; otherwise you will get an undefined method 'verbosity' error.