I have a small Sinatra app with both a staging and production environment on a single server with running Nginx. To deploy I am using Capistrano and capistrano-ext to easily deploy to different locations.
The problem that the staging environment always runs with the production configuration specified within the app.rb file.
configure :staging do
# staging settings
set :foo, "bar" # will never be set to this
end
configure :production do
# prod settings
set :foo, "rab"
end
I have come to the conclusion that the capistrano :environment variable within the deploy.rb file doesn’t config Sinatra in any way. I have also tried setting the ENV[“RACK_ENV”] to “staging” to no avail.
config/deploy/staging.rb
server "10.10.100.16", :app, :web, :db, :primary => true
set :deploy_to, "/var/www/staging.my_app"
set :environment, "staging"
set :env, "staging"
ENV["RACK_ENV"] = "staging"
Any ideas?
** Update: I should add that I am also using Passenger.
setting the rack_env variable within the nginx seems to do the trick.
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#RackEnv