Unicorn restart/upgrade doesn't work

后端 未结 4 410
难免孤独
难免孤独 2021-02-04 12:28

Following is link to my init script for unicorn. https://gist.github.com/1466775

Restart command has never worked for me. I am using upgrade to restart unicorn after eac

相关标签:
4条回答
  • 2021-02-04 12:54

    I had a very similar problem and finally found the solution

    I had looked through the logs before but obviously failed to see the (Bundler::GemfileNotFound) error. Turns out there are old references to earlier releases and once the gem file changes, the new master silently fails. Tail -f your unicorn log to see what happens. My issues were all fixed as per the link with the following in my unicorn.rb

     before_exec do |server|
        ENV['BUNDLE_GEMFILE'] = "#{root}/Gemfile"
     end 
    
    0 讨论(0)
  • 2021-02-04 12:57

    According to your init script, "/bin/init.d/unicorn restart" sends HUP signal to unicorn master process

    ------cropped

    restart|reload)
        sig HUP && echo reloaded OK && exit 0
        echo >&2 "Couldn't reload, starting '$CMD' instead"
        su - $USER -c "$CMD"
    

    -----cropped

    This is what HUP does to unicorn process :

    reloads config file and gracefully restart all workers. If the “preload_app” directive is false (the default), then workers will also pick up any application code changes when restarted. If “preload_app” is true, then application code changes will have no effect.

    What you are looking for is USR2 signal which your upgrade parameter to unicorn is already doing !

    USR2 signal re-executes the running binary. A separate QUIT should be sent to the original process once the child is verified to be up and running.

    0 讨论(0)
  • 2021-02-04 13:05

    I fixed this issue by changing my unicorn init.d script from

    CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E staging"
    

    to this:

    CMD="cd $APP_ROOT; BUNDLE_GEMFILE=$APP_ROOT/Gemfile bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E staging"
    

    Which seems to point to the new bundle gemfile on every new release. Taking inspiration from this merge request

    0 讨论(0)
  • 2021-02-04 13:06

    I had the same issue, but I was using rbenv which was installed on per user basis. I used this init script

    I figured out that since my rbenv installed on per user basis I need to slightly change this:

    CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
    

    with this:

    CMD="cd $APP_ROOT; ~/.rbenv/bin/rbenv exec bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
    

    Hope it will help you!

    P.S. or somebody else since it's an old question =)

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