Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails Env should not be set by -E parameter #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshuaballoch
Copy link

I have found that the way this gem works, the unicorn rack env parameter will overwrite the rails environment name (ENV["RAILS_ENV"] variable).

Example:

RAILS_ENV=staging BUNDLE_GEMFILE=/var/www/giga_webapp-staging/current/Gemfile bundle exec unicorn_rails -c config/unicorn.rb -E deployment -D

Expect:

  1. That the unicorn rack environment name is "deployment" (it is).
  2. That the ENV["RAILS_ENV"] variable remains as "staging"

Get:

  1. The ENV["RAILS_ENV"] variable is NOT staging; it is "deployment".
  2. I am unable to reliably use the ENV["RAILS_ENV"] variable in the unicorn.rb config file, as a result.

I recommend that these two variables/environment names should not influence each other.

  1. In a multi stage configuration, a site's rails environment may change names in each different environment (eg: Production, Staging, Development... plus other possible).
  2. Unicorn, however, supports two rack environments ("deployment" or "development" or none). These have effects on what middleware is loaded, and effects on performance http://unicorn.bogomips.org/unicorn_1.html#rack-environment
  3. Therefore, it must be possible to choose a RAILS_ENV independently of the unicorn rack environment.

The suggested code change, while it stops the RAILS_ENV variable from being overwritten, is not a full solution. I opened this pull request to discuss this issue and possible solutions, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant