capistrano / rails

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

Staging environment booting in production mode. #225

Closed alosada closed 6 years ago

alosada commented 6 years ago

Hello!

I'm trying to deploy a rails 5 app to a staging server using capistrano with nginx and passenger, however running Rails.env yields production instead of staging. Here's my capistrano setup:

in config/deploy.rb:

set :stages, %i(staging production)
set :default_stage, :staging

in config/environments/staging.rb:

set :stage, :staging
set :rails_env, :staging

running echo $RAILS_ENV in my server yields 'staging'

and my passenger_app_env config aso has staging as value

I'm not aware of anything that could override those, Any ideas?

Thanks in advance.

PD: I'm using rbenv PPD: Disclaimer: Asked in StackOverflow first!

alosada commented 6 years ago

nothing? :(

mattbrictson commented 6 years ago

Sorry, I have no experience with passenger so I do not know how its configuration works.

The only thing I can point out based on your message is that it seems you are using Capistrano's configuration incorrectly. Capistrano 3 (which I assume you are using), has no :stages or :default_stage settings; furthermore you should never use set :stage, ... because in Capistrano 3 the stage is determined by the name of the file: e.g. config/deploy/staging.rb.

Perhaps you copied your config from a Capistrano 2 tutorial by mistake?

That said, none of these problems immediately jumps out at me as necessarily affecting passenger...

Anyway, sorry I cannot help! This is why we usually direct people to Stack Overflow for support since there is a bigger audience there that is more likely to be using your particular stack. I know you said you tried that already, but perhaps it is worth another shot.

My general approach would be try to get passanger working the way you want first, without using Capistrano at all. Capistrano is a tool to help you automate what already works. Figure out how to start passenger with rbenv, etc. and only once that is solved then bring Capistrano back into the mix.

Good luck!

FernE97 commented 5 years ago

Ran into this same issue and it was because the environment was being set to production inside /etc/environment on the server.

sudo vim /etc/environment

change to...

RAILS_ENV=staging