How to say Sinatra, in what environment (development, testing, production) is this so?

(Disclaimer: New for deploying Sinatra on Heroku.)

I saw http://www.sinatrarb.com/configuration.html and it tells me set :environment, :production . My question is how can I indicate this: "when the environment is set up as a production in Geroku, stay in the test / development".

Also, even after putting the line set :environment, :production , I don’t think it works, because when I try to execute the rackup application locally, it still works (when I know (or, I think, know), that it should not, because I did not install postgres on my computer).

Gemfile

 group :production do gem 'dm-postgres-adapter' end group :development, :test do gem 'dm-sqlite-adapter', "~> 1.2.0" end 
+6
source share
2 answers

The Sinatra environment has nothing to do with gems inside a downloadable production team. They are separate and do not work with each other.

Sinatra takes the environment from the RACK_ENV environment RACK_ENV , just start it with RACK_ENV=production rackup

Bundler works a little differently, you can choose which groups it should exclude when starting the package: bundle install --without production

+12
source

Sinatra uses the environment variable APP_ENV . You can also set it explicitly through the settings as you mentioned.

A symbol that identifies the deployment environment; usually one of: development ,: test or: production. Environment: defaults to the value of the environment variable APP_ENV (ENV ['APP_ENV']), or: development when the environment variable APP_ENV is not set.

This is how you say Sinatra about the environment.

0
source

Source: https://habr.com/ru/post/956141/


All Articles