将Sinatra应用程序部署到heroku时出现Bundle和Gem错误

时间:2012-08-06 04:27:29

标签: ruby deployment heroku sinatra

更新

我做了以下操作,这是我仍然在日志中的callstack:

2012-08-06T12:30:57+00:00 heroku[slugc]: Slug compilation finished
2012-08-06T12:30:58+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 56970`
2012-08-06T12:30:59+00:00 app[web.1]: bash: bundle: command not found
2012-08-06T12:31:00+00:00 heroku[web.1]: Process exited with status 127
2012-08-06T12:31:00+00:00 heroku[web.1]: State changed from starting to crashed
2012-08-06T12:31:08+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:08+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:09+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:10+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=

我的Procfile文件现在看起来像这样:

root: = ::File.dirname(__FILE__)
require: ::File.join( root, 'app' )
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
run: WPL.new

Gemfile看起来像这样:

source :rubygems
gem 'thin'
gem 'sinatra'
gem 'shotgun'
gem 'sinatra'
gem 'mongo'
gem 'json'

我的app.rb现在看起来像这样:     要求'霰弹枪'     要求'sinatra'     要求'mongo'     要求'json / pure'

class WPL < Sinatra::Application 
  db = Mongo::Connection.new.db('docs')


  get '/' do
    File.read(File.join('public', 'index.html'))
  end
end

并且config.ru看起来像这样:

require './app'
run WPL.new

所以我正在尝试部署我的应用程序而且我遇到了几个问题。一切都在当地很好。我将应用程序推送到heroku,一切似乎都没问题但是当我检查日志时它说它无法找到命令'bundle'。

这就是我的Procfile的样子。

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

我尝试删除bundle exec,然后只是ruby app.rb -p $POST继续进行,但更多错误。

我得到的下一组错误都与宝石有关。它根本找不到任何所需的宝石。这就是我的app.rb的样子。

require 'shotgun'
require 'sinatra'
require 'mongo'
require 'json/pure'


db = Mongo::Connection.new.db('docs')


get '/' do
  File.read(File.join('public', 'index.html'))
end

我的Gemfile看起来像这样。

source :rubygems
gem 'sinatra'
gem 'shotgun'
gem 'sinatra'
gem 'mongo'
gem 'json'

我的config.ru看起来像这样。

require './app'
run Sinatra::Application

运行heroku run console也会导致此错误bundle: command not found

我错过了什么?

2 个答案:

答案 0 :(得分:0)

你的Procfile没有使用你的config.ru。

对于Sinatra应用程序,我会使用看起来像这样的Procfile:

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

This类似的问题也可能有所帮助。

答案 1 :(得分:0)

不确定发生了什么,但我刚刚在heroku上删除了我的应用并创建了一个新应用。然后它奏效了。我想当我最初创建应用程序时,heroku认为该应用程序是一个节点应用程序,因为我错过了我的Procfile。

相关问题