问题描述
我正在尝试重构我的 sinatra 代码以将我的主文件分成单独的文件,使用来自此响应,我在部署到 heroku 时遇到了麻烦.
I'm trying to refactor my sinatra code to separate my main file into separate files, using some tips from this response, and I'm having troubles deploying to heroku.
以前我没有 config.ru
文件,只是使用了我的 Procfile
,它是:
Previously I didn't have a config.ru
file, and just used my Procfile
, which was:
web: bundle exec ruby web.rb -p $PORT
根据这篇文章.
从重构开始,我现在将 Procfile
更改为
From the refactor, I've now changed my Procfile
to
web: bundle exec thin -R config.ru start -p $PORT
我的 config.ru
文件是
root = ::File.dirname(__FILE__)
require ::File.join( root, 'web' )
run MyApp.new
我的 web.rb
文件包含在一个类定义中
And my web.rb
file being contained around a class definition
class MyApp < Sinatra::Application
# ...
end
这适用于我的本地开发计算机,但是当我部署到 heroku 时,我得到
This works on my local development computer, but when I deploy to heroku, I get
2011-12-01T11:21:54+00:00 app[web.1]: bundler: command not found: thin
2011-12-01T11:21:54+00:00 app[web.1]: Install missing gem executables with `bundle install`
2011-12-01T11:21:56+00:00 heroku[web.1]: State changed from starting to crashed
2011-12-01T11:22:01+00:00 heroku[router]: Error H10 (App crashed) -> GET [my app].herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2011-12-01T11:22:02+00:00 heroku[router]: Error H10 (App crashed) -> GET [my app].herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
在heroku上没有安装thin吗?或者有没有其他方法可以通过更改在 heroku 上运行我的应用程序?
Is thin not installed on heroku? Or is there some other way of running my app on heroku with the changes?
推荐答案
我不得不更新我的 Procfile
因为 RACK_ENV
没有传递到 heroku 环境中.Procfile
变成了:
I had to update my Procfile
because the RACK_ENV
isn't passed into the heroku environment. The Procfile
became:
web: bundle exec thin -R config.ru start -p $PORT -e $RACK_ENV
这篇关于在 heroku cedar 堆栈上部署 sinatra 应用程序(使用 config.ru)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!