开发者

Problem deploying simple ruby sinatra app on heroku

I am new to ruby, git and heroku. I was trying to build a simple Hello World app and deploy it on heroku. I see the following error in the logs when I try to access the site using the heroku provided URL. Could you tell me what I am not doing right.

    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `new'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `<main>'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
    2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
 开发者_如何转开发   2011-07-03T01:15:06+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
    2011-07-03T01:15:06+00:00 heroku[web.1]: Process exited
    2011-07-03T01:15:07+00:00 heroku[web.1]: State changed from starting to crashed

config.ru file

    require 'myapp2'
    run Sinatra::Application

myapp2.rb

    require 'rubygems'
    require 'sinatra'

    get '/' do
    'Hello World'
    end


You're missing the top of the stack trace, but it looks like the problem is the require.

In config.ru change

require 'myapp2'

to

require './myapp2'

or

require File.expand_path("../myapp2", __FILE__)

Ruby 1.9.2 no longer has the current directory in the load path, so require 'myapp2' isn't able to find your app file which is in the same directory.

If this is working on your local machine, but not on Heroku, then you're likely using a different version of Ruby, probably 1.8.7. It would be a good idea to install 1.9.2 locally so that you're using the same version in development and production. Alternatively you could change the Heroku stack you're using; have a look at the Heroku stack docs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜