capistrano-unicorn
capistrano-unicorn copied to clipboard
v0.2.0 failed to restart unicon due to incorrect pid file path
I noticed that this gem failed to restart unicorn after I upgraded to v0.2.0, due to the missing of app_path
.
0.2.0
executing "if [ -e tmp/pids/unicorn.pid ] && kill -0 `cat tmp/pids/unicorn.pid` >
0.1.10
executing "if [ -e /u/apps/avcloud/current/tmp/pids/unicorn.pid ] && kill -0 `cat /u/apps/avcloud/current/tmp/pids/unicor
I'm using a multistage cap. Not sure if that's related.
It happens on unicorn:stop
, restart
etc.
+1
+1
+1
As I understand relative paths to pid file in config/unicorn.rb stopped working, now it works only with absolute path.
In my case I'm receiving:
* 2013-12-05 10:18:00 executing `unicorn:reload'
triggering before callbacks for `unicorn:reload'
/tmp/unicorn.rb20131205-11768-d8q40k:7:in `read': No such file or directory - config/unicorn/production.rb (Errno::ENOENT)
from /tmp/unicorn.rb20131205-11768-d8q40k:7:in `reload'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:75:in `instance_eval'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:75:in `reload'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:68:in `initialize'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:108:in `new'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:108:in `initialize'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/bin/unicorn:126:in `new'
from /home/morman/.gem/ruby/1.9.3/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
from /home/morman/.gem/ruby/1.9.3/bin/unicorn:23:in `load'
from /home/morman/.gem/ruby/1.9.3/bin/unicorn:23:in `<main>'
*** err :: failed to auto-detect pid from config/unicorn/production.rb
*** err :: falling back to default: /home/deploy/web/printbox/current/tmp/pids/unicorn.pid
Even though config/unicorn/production.rb
exists in rails app. Works fine with 0.1.10.
Maybe the bug is related to my case.
I set pid
in config/unicorn/production.rb
like this:
pid File.expand_path('tmp/pids/unicorn.pid', ENV['RAILS_ROOT']).to_s
From 0.2.0 capistrano-unicorn
auto-detects pid path from the config file and pid
above is evaluated at local machine which is different from server's path.
I think:
- Auto-detecting should run on server's environment and then
- For relative path, the path extracted here should be wrapped by
File.expand_path
@k2nr Sounds great! Would you please send us a pull request with that patch? If you could add/fix/identify relevant specs, that'd be excellent.
@guangnan, @cschramm, @jnimety, @glebtv, @michalorman - it would help us a lot in fully understanding this issue if you could provide:
- the value of
unicorn_pid
(if any) in your capistrano config file, and - the value of
pid
in your unicorn config file
pid 'tmp/pids/unicorn.pid'
@k2nr, @sfsekaran - I already carefully considered server-side detection, tried to implement it, and then rejected it. So I'm not yet convinced this is the way to go.
pid "/var/www/app_name/shared/pids/unicorn.pid"
pid File.expand_path('../../../tmp/pids/unicorn.pid', __FILE__)
I had this error and fixed it setting the pid folder in my capistrano deploy file:
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
@lecoueyl Awesome! it worked well I think capistrano is having trouble with unicorn on recognising the pids and it seems like a good solution doing the job manually.
In fact, this is the default folder setting in capistrano-unicorn. But capistrano is not setting it so you have to do it by hand :)