我如何告诉西纳特拉什么样的环境(开发,测试,生产)? [英] How do I tell Sinatra what environment (development, test, production) it is?

查看:191
本文介绍了我如何告诉西纳特拉什么样的环境(开发,测试,生产)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(免责声明:在Heroku上部署Sinatra的新手。)

(Disclaimer: New to deploying Sinatra on Heroku.)

我曾见过 http://www.sinatrarb.com/configuration.html ,它告诉我 set:environment,:production 。我的问题是,我该如何指定它:在Heroku中,将环境设置为生产,否则停留在测试/开发中。

另外,即使在将该行 set:environment,:production ,我不认为它正在工作,因为当我尝试 rackup 时它仍然在运行(当我知道(或者我想我知道)它不应该是因为我没有在我的电脑上安装postgres)。

I have seen http://www.sinatrarb.com/configuration.html and it tells me to set :environment, :production. My question is, how can I specify it to do: "when in Heroku, set environment as production, else stay in test/development."

Gemfile

Gemfile 

推荐答案

Sinatra环境与正在加载的生产组内的宝石无关。这些是独立的,不能相互工作。

The Sinatra environment has nothing to do with the gems inside the production group being loaded. These are separate and don't work with each other.

Sinatra从 RACK_ENV 环境变量中使用环境,只需从 RACK_ENV =生产rackup

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

开始它,Bundler的工作方式有点不同,您可以选择它应该排除的组当运行bundle install时: bundle install --without production

Bundler works a bit different, you can choose which groups it should exclude when running bundle install: bundle install --without production

这篇关于我如何告诉西纳特拉什么样的环境(开发,测试,生产)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆