我在 Heroku 上的“应用程序启动”时收到此错误。在本地主机上一切正常。
app.rb (Sinatra)
require 'uri'
require 'sinatra'
require 'mongo'
require "bson"
require 'chartkick'
require 'omniauth-facebook'
include Mongo
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :facebook, "KEY", "SECRET", :scope => 'read_stream'
end
#### DATABASE #######
def get_connection
return @db_connection if @db_connection
db = URI.parse(ENV['MONGOHQ_URL'] || 'mongodb://localhost/facebook')
db_name = db.path.gsub(/^\//, '')
@db_connection = Mongo::Connection.new(db.host, db.port).db(db_name)
@db_connection.authenticate(db.user, db.password) unless (db.user.nil? || db.user.nil?)
@db_connection
end
db = get_connection
宝石文件
source 'https://rubygems.org'
ruby '2.0.0'
gem 'mongo'
gem "bson"
gem 'bson_ext'
gem "sinatra"
gem "koala", "~> 1.7.0rc1"
gem "chartkick"
gem 'omniauth-facebook'
配置.ru
require './app'
run Sinatra::Application
** Heroku 日志 **
Slug compilation finished
2013-09-16T12:32:07.666778+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-16T12:32:11.011518+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 21566`
2013-09-16T12:32:12.324776+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:419:in `construct_query_message': uninitialized constant BSON::ByteBuffer (NameError)
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/app.rb:21:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:405:in `send_initial_query'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/app.rb:21:in `get_connection'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:371:in `refresh'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/app.rb:26:in `<top (required)>'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/config.ru:1:in `require'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:87:in `next_document'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/config.ru:1:in `block in <main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/db.rb:498:in `command'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `<main>'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:704:in `check_is_master'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/config.ru:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:504:in `connect'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/config.ru:in `<main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
2013-09-16T12:32:12.324776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize'
2013-09-16T12:32:12.325003+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
2013-09-16T12:32:12.325160+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `load'
2013-09-16T12:32:13.530315+00:00 heroku[web.1]: Process exited with status 1
2013-09-16T12:32:13.544931+00:00 heroku[web.1]: State changed from starting to crashed