Commit ce703f5e165b2e7dcb17800e9372a138f39b4f3f
Exists in
master
and in
1 other branch
Merge pull request #833 from jlecour/patch-3
Unicorn deploy tweaks
Showing
1 changed file
with
15 additions
and
5 deletions
Show diff stats
config/deploy.example.rb
| ... | ... | @@ -69,7 +69,7 @@ namespace :db do |
| 69 | 69 | end |
| 70 | 70 | end |
| 71 | 71 | |
| 72 | -set :unicorn_pidfile, "#{fetch(:deploy_to)}/shared/pids/unicorn.pid" | |
| 72 | +set :unicorn_pidfile, "#{fetch(:deploy_to)}/shared/tmp/pids/unicorn.pid" | |
| 73 | 73 | set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`" |
| 74 | 74 | |
| 75 | 75 | namespace :unicorn do |
| ... | ... | @@ -77,7 +77,13 @@ namespace :unicorn do |
| 77 | 77 | task :start do |
| 78 | 78 | on roles(:app) do |
| 79 | 79 | within current_path do |
| 80 | - execute "UNICORN_PID=\"#{fetch(:unicorn_pidfile)}\"", "bundle exec unicorn -D -c ./config/unicorn.rb" | |
| 80 | + if test " [ -s #{fetch(:unicorn_pidfile)} ] " | |
| 81 | + warn "Unicorn is already running." | |
| 82 | + else | |
| 83 | + with "UNICORN_PID" => fetch(:unicorn_pidfile) do | |
| 84 | + execute :bundle, :exec, :unicorn, "-D -c ./config/unicorn.rb" | |
| 85 | + end | |
| 86 | + end | |
| 81 | 87 | end |
| 82 | 88 | end |
| 83 | 89 | end |
| ... | ... | @@ -85,21 +91,25 @@ namespace :unicorn do |
| 85 | 91 | desc 'Reload unicorn' |
| 86 | 92 | task :reload do |
| 87 | 93 | on roles(:app) do |
| 88 | - execute :kill, "-HUP #{fetch(:unicorn_pid)}" | |
| 94 | + execute :kill, "-HUP", fetch(:unicorn_pid) | |
| 89 | 95 | end |
| 90 | 96 | end |
| 91 | 97 | |
| 92 | 98 | desc 'Stop unicorn' |
| 93 | 99 | task :stop do |
| 94 | 100 | on roles(:app) do |
| 95 | - execute :kill, "-QUIT #{fetch(:unicorn_pid)}" | |
| 101 | + if test " [ -s #{fetch(:unicorn_pidfile)} ] " | |
| 102 | + execute :kill, "-QUIT", fetch(:unicorn_pid) | |
| 103 | + else | |
| 104 | + warn "Unicorn is not running." | |
| 105 | + end | |
| 96 | 106 | end |
| 97 | 107 | end |
| 98 | 108 | |
| 99 | 109 | desc 'Reexecute unicorn' |
| 100 | 110 | task :reexec do |
| 101 | 111 | on roles(:app) do |
| 102 | - execute :kill, "-USR2 #{fetch(:unicorn_pid)}" | |
| 112 | + execute :kill, "-USR2", fetch(:unicorn_pid) | |
| 103 | 113 | end |
| 104 | 114 | end |
| 105 | 115 | end | ... | ... |