how to restart unicorn manually

跟風遠走 提交于 2019-11-29 02:26:36

问题


I'm not confident that unicorn is restarting properly when I run cap deploy as certain changes are not showing in the app, therefore I wanted to restart unicorn manually on my remote server. I have navigated into etc/init.d and see a listing for unicorn_myapp but it's not a directory (i.e. I can't cd into it). Based on the code below from my deploy.rb file, is there something I can do from here to restart unicorn?

I tried to do run unicorn_myapp restart but it said run isn't a command

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

回答1:


you didn't list the OS. but one of the following should work.

you will need to be root / use sudo

/etc/init.d/unicorn_myapp restart 


/etc/init.d/unicorn_myapp stop 
/etc/init.d/unicorn_myapp start 


service unicorn_myapp restart

service unicorn_myapp stop
service unicorn_myapp start

Try the restart versions first, but depending upon how the init script was written it might not have a restart command, if that doesn't work you can do the stop / start version.




回答2:


Alternatively, instead of relying on /etc/init.d... scripts which are OS dependent, a simple way to restart unicorn is to send HUP (1) signal to its master process.

Here is for instance how I reload an app automatically after a git push via post-receive hook:

#!/bin/sh
unicorn_pid=`cat /tmp/pids/unicorn.pid`
echo "Restarting Unicorn ($unicorn_pid)"
kill -HUP $unicorn_pid

In your case, /etc/init.d/unicorn_myapp restart script is probably doing this. Check the unicorn.conf for the location of its pidfile.

For more details, see unicorn SIGNALS documentations




回答3:


You might have to be root, but it should just be /etc/init.d/unicorn_myapp restart (don't include run, which is not a shell command).



来源:https://stackoverflow.com/questions/19352125/how-to-restart-unicorn-manually

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!