capistrano3-unicorn icon indicating copy to clipboard operation
capistrano3-unicorn copied to clipboard

Point Unicorn to current/Gemfile instead of release dir.

Open amw opened this issue 11 years ago • 4 comments

Without this env variable unicorn master process remembers path to Gemfile of specific release. This causes two problems when reloading unicorn using USR2 signal:

  1. Gems are not refreshed if Gemfile has changed since the release when unicorn was started.
  2. If the release from which unicorn was started is removed due to keep_releases option, unicorn will fail to reload (since that Gemfile is no longer available).

You need to cap stage unicorn:stop && cap stage unicorn:start for this fix to be applied.

amw avatar Sep 09 '14 13:09 amw

Out of curiosity since we've seen this issue before and have had various changes relating to it does your unicorn.rb file have the following defined as shown in the example configuration?

# use correct Gemfile on restarts
before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
end

mlineen avatar Sep 09 '14 15:09 mlineen

No, it does not. I guess that's one way to fix this issue.

I do think that setting the env variable when starting unicorn is safer though. That's what the old capistrano-unicorn gem did and it's the only issue I've had with the migration.

amw avatar Sep 09 '14 15:09 amw

When we were last working on this issue, it seemed that without this defined in the unicorn.rb the USR2 signal still had issues identifying the correct Gemfile on restart. I haven't managed to write a set of tests verifying this however.

mlineen avatar Sep 09 '14 15:09 mlineen

I don't have a set of tests, but it fixed my production app without adding anything about gemfile to my unicorn.rb. Maybe you were testing without stopping unicorn first?

amw avatar Sep 09 '14 15:09 amw