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,7 +69,7 @@ namespace :db do | ||
69 | end | 69 | end |
70 | end | 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 | set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`" | 73 | set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`" |
74 | 74 | ||
75 | namespace :unicorn do | 75 | namespace :unicorn do |
@@ -77,7 +77,13 @@ namespace :unicorn do | @@ -77,7 +77,13 @@ namespace :unicorn do | ||
77 | task :start do | 77 | task :start do |
78 | on roles(:app) do | 78 | on roles(:app) do |
79 | within current_path do | 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 | end | 87 | end |
82 | end | 88 | end |
83 | end | 89 | end |
@@ -85,21 +91,25 @@ namespace :unicorn do | @@ -85,21 +91,25 @@ namespace :unicorn do | ||
85 | desc 'Reload unicorn' | 91 | desc 'Reload unicorn' |
86 | task :reload do | 92 | task :reload do |
87 | on roles(:app) do | 93 | on roles(:app) do |
88 | - execute :kill, "-HUP #{fetch(:unicorn_pid)}" | 94 | + execute :kill, "-HUP", fetch(:unicorn_pid) |
89 | end | 95 | end |
90 | end | 96 | end |
91 | 97 | ||
92 | desc 'Stop unicorn' | 98 | desc 'Stop unicorn' |
93 | task :stop do | 99 | task :stop do |
94 | on roles(:app) do | 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 | end | 106 | end |
97 | end | 107 | end |
98 | 108 | ||
99 | desc 'Reexecute unicorn' | 109 | desc 'Reexecute unicorn' |
100 | task :reexec do | 110 | task :reexec do |
101 | on roles(:app) do | 111 | on roles(:app) do |
102 | - execute :kill, "-USR2 #{fetch(:unicorn_pid)}" | 112 | + execute :kill, "-USR2", fetch(:unicorn_pid) |
103 | end | 113 | end |
104 | end | 114 | end |
105 | end | 115 | end |