質問

I have the following tasks in my deploy.rb

namespace :unicorn do
  desc "stop unicorn"
  task :stop, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} kill `cat #{unicorn_pid}`"
  end 
  desc "start unicorn"
  task :start, :roles => :app, :except => { :no_release => true } do
    run "cd #{current_path} && #{try_sudo} unicorn -c #{current_path}/config/unicorn.rb -E #{rails_env} -D"
  end
  task :reload, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
  end

  after "deploy:restart", "unicorn:reload"
end

When I run unicorn:start or unicorn:reload tasks from my development machine everything looks fine on the server:

$ ps aux | grep unicorn
myuser   8196 77.9 12.2  81020 62748 ?        Sl   19:18   0:14 unicorn master -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D                                                                                       
myuser   8216  0.0 11.5  81020 59232 ?        Sl   19:18   0:00 unicorn worker[0] -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D

However when I run a full-on cap deploy I get multiple instances of the unicorn server, which confuses the hell out of nginx.

$ ps aux | grep unicorn
myuser   8196  4.4 12.2  81020 62764 ?        Sl   19:18   0:14 unicorn master (old) -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D                                                                                 
myuser   8216  1.1 13.2  87868 67764 ?        Sl   19:18   0:03 unicorn worker[0] -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D                                                                                    
myuser   8362  5.8 12.8  83448 65408 ?        Sl   19:19   0:16 unicorn master -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D                                                                                       
myuser   8385  0.0 12.1  83712 61980 ?        Sl   19:19   0:00 unicorn worker[0] -c /home/myuser/www/myapp/current/config/unicorn.rb -E production -D

I have no idea why unicorn:reload is spinning up these duplicate instances on deploy. Apparently it's not stopping the previous master/worker. I have to run the unicorn:stop task twice then unicorn:start again to rectify the problem

Anyone else run into this? I've been poking at it for hours without any luck

役に立ちましたか?

解決

So it looks like the issue was a faulty unicorn install. I nuked my gems and rebundled and now everything is sweet. Unicorn version is the same so it's still a bit of a mystery but at least it's working now

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top