capistrano / rails

Official Ruby on Rails specific tasks for Capistrano
http://www.capistranorb.com/
MIT License
867 stars 270 forks source link

Application is running in Production instead of Staging #240

Closed aamir-nazir closed 4 years ago

aamir-nazir commented 4 years ago

I have spent reasonable time on looking the answers but neither of them worked for me. I have specified correct app environment on server and in staging.rb but something strange happening. During deployment Capistrano deploys application in staging env however actual application on server keeps running in Production mode, expecting production database instead of staging which was setup during Capistrano deployment. Here are the contents of staging.rb

set :stage, :staging
server 'XXX.XXX.XXX.XXX', user: 'root', roles: %w{app db web}
set :branch, 'staging'
set :rails_env, 'staging'

Expected behavior

Application should be running in staging environment

Actual behavior

Application is running in production environment

System configuration

https://gist.github.com/aamir-nazir/e6217041620f7c9531438b83e378cd4a

mattbrictson commented 4 years ago

The :rails_env variable set by the capistrano-rails gem only controls the Rails environment used by commands issued via Capistrano. For example, it is used by the assets:precompile cap task when running rake assets:precompile.

However running the Rails server itself is outside the scope of the capistrano-rails gem. How are you running the server? Are you using Passenger, for example? You will need to refer to the documentation for the server for how to specify the desired Rails environment.

aamir-nazir commented 4 years ago

Application server being used for application is Puma. capistrano/puma is being used to run it.

mattbrictson commented 4 years ago

OK, then I suggest checking out the https://github.com/seuros/capistrano-puma repo for documentation or to ask a question. The capistrano-puma gem is not maintained by the Capistrano team. I've not used that gem so I'm afraid I can't be of much help. Based on their documentation I would first check the contents of /var/www/ProjectName/shared/puma.rb on the server to verify it contains the configuration you expect.

aamir-nazir commented 4 years ago

I thought it's the same team managing all Capistrano gems however it's not the case. @mattbrictson Thanks for your support, really appreciated.