问题描述
我有一个自制的Sinatra应用程序,打算使用Heroku对其进行托管.
I have a homemade Sinatra application for which I intend to use Heroku to host it.
我在开发中使用工头和and弹枪,具有以下Procfile:
I use foreman and shotgun in development, with the following Procfile:
web: shotgun config.ru -s thin -o 0.0.0.0 -p $PORT -E $RACK_ENV
它既适用于开发,也适用于生产.但事实是,我不想在生产中使用shot弹枪,因为它太慢了.
It works great with both development and production. But the thing is, I don't want to use shotgun in production since it's too slow.
推荐答案
您可以使用两个Procfiles
(例如Procfile
和Procfile.dev
)并使用 foreman
的-f
选项,以选择要在dev中使用的另一个选项:
You could use two Procfiles
(e.g. Procfile
and Procfile.dev
) and use foreman
s -f
option to select a different one to use in dev:
在开发人员中(Procfile.dev
包含您的shotgun
网络流程):
In dev (Procfile.dev
contains your shotgun
web process):
foreman start -f Procfile.dev
在生产中,foreman start
将拾取普通的Procfile
.
In production, foreman start
will pick up the normal Procfile
.
或者,您可以使用脚本在应用程序中创建bin
目录,以根据$RACK_ENV
启动相应的Web服务器(我在工头创建者的评论,因此值得考虑).
Alternatively you could create a bin
directory in your app with a script to start the appropriate web server depending on $RACK_ENV
(an idea I found in a comment made by the creator of Foreman, so worth considering).
这篇关于工头:在开发和生产中使用不同的Procfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!