Thursday, 19 September 2013

Capistrano-uniocorn gem multistage environment defaulting to unicorn_rails and -E production

Capistrano-uniocorn gem multistage environment defaulting to unicorn_rails
and -E production

I've been using this gem for a while 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.
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/bundio/current/config/unicorn.rb", "-E", "production",
"-D", {12=>#<Kgio::UNIXServer:/tmp/bundio.socket>,
13=>#<Kgio::TCPServer:fd 13>}] (in /var/www/apps/bundio/current)
Here's the output from cap -T (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 (see unicorn docs for
settings of the RACK_ENV variable.
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
# Following recommendations from http://unicorn.bogomips.org/unicorn_1.html
fetch(:rails_env) == 'development' ? 'development' : 'deployment'
end
Thanks in advance.

No comments:

Post a Comment