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

时间:2011-12-01 11:54:39

标签: ruby deployment heroku sinatra

我尝试重构我的sinatra代码,将我的主文件分成单独的文件,使用this response中的一些提示,并且我遇到了部署到heroku的麻烦。

之前我没有config.ru个文件,只使用了我的Procfile,其中包括:

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

根据this article

从重构中,我现在已将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=

在heroku上没有安装瘦吗?或者是否有其他方法在heroku上运行我的应用程序并进行更改?

1 个答案:

答案 0 :(得分:9)

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

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