capistrano-unicorn icon indicating copy to clipboard operation
capistrano-unicorn copied to clipboard

v0.2.0 failed to restart unicon due to incorrect pid file path

Open chengguangnan opened this issue 11 years ago • 15 comments

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.

chengguangnan avatar Nov 05 '13 13:11 chengguangnan

+1

cschramm avatar Nov 12 '13 12:11 cschramm

+1

jnimety avatar Nov 14 '13 22:11 jnimety

+1

glebtv avatar Nov 21 '13 00:11 glebtv

As I understand relative paths to pid file in config/unicorn.rb stopped working, now it works only with absolute path.

glebtv avatar Nov 21 '13 00:11 glebtv

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.

michalorman avatar Dec 05 '13 09:12 michalorman

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 avatar Dec 12 '13 05:12 k2nr

@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.

sfsekaran avatar Dec 12 '13 21:12 sfsekaran

@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

aspiers avatar Dec 13 '13 12:12 aspiers

pid 'tmp/pids/unicorn.pid'

cschramm avatar Dec 13 '13 12:12 cschramm

@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.

aspiers avatar Dec 13 '13 13:12 aspiers

pid "/var/www/app_name/shared/pids/unicorn.pid"

RobWu avatar Dec 13 '13 13:12 RobWu

pid File.expand_path('../../../tmp/pids/unicorn.pid', __FILE__)

jnimety avatar Dec 13 '13 14:12 jnimety

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 avatar Jan 21 '15 02:01 lecoueyl

@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.

wonook avatar Jan 27 '15 09:01 wonook

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 :)

lecoueyl avatar Jan 27 '15 23:01 lecoueyl