Search code examples
ruby-on-railsunicorn

how to restart unicorn manually


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

Solution

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