Deploying sinatra app (with config.ru) on heroku cedar stack

孤人 提交于 2019-12-03 18:44:13

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/8340943/deploying-sinatra-app-with-config-ru-on-heroku-cedar-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!