Restart Unicorn issue (capistrano)

前端 未结 3 548
有刺的猬
有刺的猬 2020-12-13 11:47

I\'ve got following settings in deploy.rb to restart my server:

namespace :deploy do
  task :restart do
    run \"if [ -f #{unicorn_pid} ] &&         


        
相关标签:
3条回答
  • 2020-12-13 12:03

    Maybe this is because of the way unicorn restarts. Not every worker is restarted immediately. This is to make it possible to have zero downtime and loose no requests. If you want to see your changes for sure, try to stop and then start your application instead. I have had to do this some times. Of course you will potentially loose some request.

    The following tasks is what I use for restarting, stopping, and starting my unicorn server.

    desc "Zero-downtime restart of Unicorn"
    task :restart, :except => { :no_release => true } do
      run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
    end
    
    desc "Start unicorn"
    task :start, :except => { :no_release => true } do
      run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D -E production"
    end
    
    desc "Stop unicorn"
    task :stop, :except => { :no_release => true } do
      run "kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
    end
    

    Hope this helps you.

    Maybe this article is of interest.

    0 讨论(0)
  • 2020-12-13 12:04

    see here my baby~ Restarting Unicorn with USR2 doesn't seem to reload production.rb settings

    Keep in mind that: your working directory in unicorn.rb should be : /your/cap/directory/current

    NOT be: File.expand_path("../..", FILE)

    Because the unicorn and linux soft link forking error: soft link can not work well.

    0 讨论(0)
  • 2020-12-13 12:17

    You should give capistrano-unicorn a try, that's what I currently use with the default hooks mentioned below.

    Setup

    Add the library to your Gemfile:

    ruby group :development do gem 'capistrano-unicorn', :require => false end

    And load it into your deployment script config/deploy.rb:

    ruby require 'capistrano-unicorn'

    Add unicorn restart task hook:

    ruby after 'deploy:restart', 'unicorn:reload' # app IS NOT preloaded after 'deploy:restart', 'unicorn:restart' # app preloaded after 'deploy:restart', 'unicorn:duplicate' # before_fork hook implemented (zero downtime deployments)

    0 讨论(0)
提交回复
热议问题