【问题标题】:How to configure config.ru to get Resque to run on Heroku?如何配置 config.ru 让 Resque 在 Heroku 上运行?
【发布时间】:2011-10-17 22:34:10
【问题描述】:

我的config.ru 文件中有以下内容,这会使 Heroku 崩溃,并在其下方显示错误。

require ::File.expand_path('../config/environment',  __FILE__)
run Picasa::Application

require 'resque/server'
run Rack::URLMap.new \
  "/" => Picasa::Application,
  "/resque" => Resque::Server.new

错误:

2011-10-17T13:54:01+00:00 heroku[web.1]: Starting process with command `thin -p 30071 -e production -R /home/heroku_rack/heroku.ru start`
2011-10-17T13:54:06+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/gems/railties-3.0.9/lib/rails/application.rb:168:in `call': undefined method `reverse_merge!' for #<Rack::URLMap:0x7fd215e4f720> (NoMethodError)
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:73:in `to_app'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `inject'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:73:in `each'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:73:in `inject'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:73:in `to_app'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:63:in `map'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:18
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `new'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
2011-10-17T13:54:06+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `new'
2011-10-17T13:54:06+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1
2011-10-17T13:54:06+00:00 heroku[web.1]: Process exited
2011-10-17T13:54:08+00:00 heroku[web.1]: State changed from starting to crashed

【问题讨论】:

    标签: ruby-on-rails heroku resque


    【解决方案1】:

    看起来您正在运行 Rails 3.0.9,在这种情况下您需要做的就是

    mount Resque::Server.new, :at => "/resque"
    

    在您的 routes.rb 文件中。

    【讨论】:

    • 嗨,约翰。将其添加到我的路由文件中,并从 config.ru 中删除了最后 4 行,并且有相同的错误。
    • 它在本地工作吗?即使没有部署到 Heroku,这个问题仍然会在本地出现。
    • 根据您在 routes.rb 文件中的建议以及我的配置文件中没有任何 Resque 特定内容,服务器确实在本地启动。
    • 这样你就可以在本地访问 /resque 了吗?当你添加到 git 并推送到 heroku 时,/resque 会给你什么?
    • 很奇怪。它现在可以工作了,使用我之前尝试过的相同的 git commit,即使它给了我与上面相同的错误。
    猜你喜欢
    • 2011-11-07
    • 2012-05-17
    • 2014-02-08
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多