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

Cannot figure out multistage environment, unicorn_rails and -E flag #78

Open
danman01 opened this issue Sep 19, 2013 · 0 comments
Open

Comments

@danman01
Copy link

I've been using this gem for a while (awesome - thanks!) and just took the dive to try deploying an actual staging environment to my staging server, and I ran into issues. Unicorn starts with the command unicorn_rails and -E production despite all the settings being correct afaik.

This may be something unique to my machine, so asking on stack overflow as well: http://stackoverflow.com/questions/18902002/capistrano-uniocorn-gem-multistage-environment-defaulting-to-unicorn-rails-and

I noticed in deploy.rb that my unicorn_bin variable was set as unicorn_rails. I took out this setting in my deploy.rb. However unicorn:duplicate still executes the unicorn_rails command, when the default should be unicorn.

My vars are all set to staging in the deploy/staging.rb, as outlined in the multistage setup wiki document, but I noticed -E is still getting set to production.

Relevent info:

Here's my output from my unicorn.log file after a deploy:

executing ["/var/www/apps/myapp/shared/bundle/ruby/2.0.0/bin/unicorn_rails", "-c",
"/var/www/apps/myapp/current/config/unicorn.rb", "-E", "production", "-D",
{12=>#<Kgio::UNIXServer:/tmp/myapp.socket>, 13=>#<Kgio::TCPServer:fd 13>}] (in /var/www/apps/myapp/current)

Here's the output from cap unicorn:show_vars (defaults to staging)

# Environments
rails_env "staging"
unicorn_env "staging"
unicorn_rack_env "staging"

# Execution
unicorn_user nil
unicorn_bundle "/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/bundle"
unicorn_bin "unicorn"
unicorn_options "" unicorn_restart_sleep_time 2`

# Relative paths
app_subdir ""
unicorn_config_rel_path "config"
unicorn_config_filename "unicorn.rb"
unicorn_config_rel_file_path "config/unicorn.rb"
unicorn_config_stage_rel_file_path "config/unicorn/staging.rb"

# Absolute paths
app_path "/var/www/apps/myapp/current"
unicorn_pid "/var/www/apps/myapp/shared/pids/unicorn.myapp.pid"
bundle_gemfile "/var/www/apps/myapp/current/Gemfile"
unicorn_config_path "/var/www/apps/myapp/current/config"
unicorn_config_file_path "/var/www/apps/myapp/current/config/unicorn.rb"
unicorn_config_stage_file_path
-> "/var/www/apps/myapp/current/config/unicorn/staging.rb"

And another curiousity, the unicorn_rails -E flag should reference the rails environment, whereas the unicorn -E should reference the rack env -- the rack env should only get the values developement and deployment, but it gets set to production, which is a bit strange.

Any insight into this would be much appreciated. On my staging server, I've also set the RAILS_ENV to staging. I've set up the things for rails for another environment, like adding staging.rb in my environments folder, adding a staging section to database.yml, etc.

important lines in lib/capistrano-unicorn/config.rb talking about unicorn_rack_env:

_cset(:unicorn_env) { fetch(:rails_env, 'production' ) } _cset(:unicorn_rack_env) do fetch(:rails_env) == 'development' ? 'development' : 'deployment' end
(references Following recommendations from http://unicorn.bogomips.org/unicorn_1.html)
Thanks in advance.

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

No branches or pull requests

1 participant