在heroku cedar堆栈上部署sinatra应用程序(使用config.ru)

发布于 2024-12-18 20:48:52 字数 1444 浏览 2 评论 0原文

我正在尝试使用此响应中的一些提示来重构我的 sinatra 代码,将我的主文件分成单独的文件,并且我在部署到 heroku 时遇到问题。

以前我没有 config.ru 文件,只使用了我的 Procfile,它是:

web: bundle exec ruby web.rb -p $PORT

按照 这篇文章

通过重构,我现在已将我的 Procfile 更改为

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 文件包含在类定义

class MyApp < Sinatra::Application
  # ...
end

这适用于我的本地开发计算机,但是当我部署到 heroku 时,我得到

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=

Is Thin notinstalled on heroku?或者是否有其他方法可以通过更改在 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.

Previously I didn't have a config.ru file, and just used my Procfile, which was:

web: bundle exec ruby web.rb -p $PORT

as per this article.

From the refactor, I've now changed my Procfile to

web: bundle exec thin -R config.ru start -p $PORT

With my config.ru file being

root = ::File.dirname(__FILE__)
require ::File.join( root, 'web' )
run MyApp.new

And my web.rb file being contained around a class definition

class MyApp < Sinatra::Application
  # ...
end

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=

Is thin not installed on heroku? Or is there some other way of running my app on heroku with the changes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2024-12-25 20:48:52

我必须更新我的 Procfile,因为 RACK_ENV 未传递到 heroku 环境中。 Procfile 变成:

web: bundle exec thin -R config.ru start -p $PORT -e $RACK_ENV

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文