Commit ca541c98915fd42e79af7b93c831097d9efb86a8
1 parent
9d2a5007
Exists in
master
and in
1 other branch
Add unicorn tasks
Showing
3 changed files
with
26 additions
and
1 deletions
Show diff stats
Gemfile
config/config.example.yml
... | ... | @@ -53,6 +53,8 @@ deployment: |
53 | 53 | repository: http://github.com/errbit/errbit.git |
54 | 54 | user: deploy |
55 | 55 | deploy_to: /var/www/apps/errbit |
56 | + # setup path to unicorn pids folder (or deploy_to/shared/pids will be used) | |
57 | + # pids: /var/www/apps/errbit/shared/pids | |
56 | 58 | |
57 | 59 | # GitHub OAuth configuration |
58 | 60 | # If you want to allow authentication via GitHub, you will need to register | ... | ... |
config/deploy.example.rb
... | ... | @@ -39,6 +39,8 @@ set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't d |
39 | 39 | set :branch, defer { current_branch } |
40 | 40 | |
41 | 41 | after 'deploy:update_code', 'errbit:symlink_configs' |
42 | +# uncomment if unicorn is running on production (do not forget to setup config) | |
43 | +# after 'deploy:restart', 'unicorn:stop' | |
42 | 44 | |
43 | 45 | namespace :deploy do |
44 | 46 | task :start do ; end |
... | ... | @@ -72,3 +74,24 @@ namespace :db do |
72 | 74 | end |
73 | 75 | end |
74 | 76 | |
77 | +namespace :unicorn do | |
78 | + set(:unicorn_pid) do | |
79 | + path = config['pids'] || "#{deploy_to}/shared/pids" | |
80 | + "`cat #{path}/unicorn.pid`" | |
81 | + end | |
82 | + | |
83 | + desc 'Reload unicorn' | |
84 | + task :reload, :roles => :app, :except => { :no_release => true } do | |
85 | + run "kill -HUP #{unicorn_pid}" | |
86 | + end | |
87 | + | |
88 | + desc 'Stop unicorn' | |
89 | + task :stop, :roles => :app, :except => { :no_release => true } do | |
90 | + run "kill -QUIT #{unicorn_pid}" | |
91 | + end | |
92 | + | |
93 | + desc 'Reexecute unicorn' | |
94 | + task :reexec, :roles => :app, :except => { :no_release => true } do | |
95 | + run "kill -USR2 #{unicorn_pid}" | |
96 | + end | |
97 | +end | ... | ... |