Adds tasks to manage Unicorn processes.
Each task tries to mirrors the Unicorn semantic :
deploy:start: start a new process if none is runningdeploy:stop: gracefully stop the process if founddeploy:shutdown: kill the process immediatelydeploy:restart: stop then startdeploy:upgrade: replace the process with a new one, without downtimedeploy:add_worker: increment the number of worker processes by onedeploy:rem_worker: decrement the number of worker processes by onedeploy:reopen_logs: reopen all logs owned by the master and all workers
By default, after a deploy is finished (after the :publishing event), deploy:upgrade is executed to perform a complete restart of the process, without downtime.
Add this line to your application's Gemfile:
gem 'capistrano-unicorn'And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-unicorn
To enable the recipe, add this to your Capfile :
require 'capistrano/unicorn'You can use the gem without any further configuration, but you can adjust some settings :
unicorn_pidfile: path of the PID file (#{current_path}/tmp/pids/unicorn.pidby default)unicorn_env: environment to start the process in (fetching:rails_envby default)unicorn_bin: name of the executable (unicornby default)unicorn_roles: capistrano roles to use (:appby default)unicorn_upgrade_timeout: tiemout (in seconds) after upgrade, before showing an error (60by default)unicorn_action_after_publish: action to exectute at the end of the deploy (:upgradeby default)
For example, you can add this to your deploy.rb :
set :unicorn_action_after_publish, -> { "deploy:restart" }It will perform a hard restart of Unicorn,instead of an upgrade.
- Fork it ( https://github.com/jlecour/capistrano-unicorn/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request