【问题标题】:What goes in config.ru for a non-rails app on heroku?Heroku 上的非 Rails 应用程序在 config.ru 中有什么内容?
【发布时间】:2013-03-31 03:44:40
【问题描述】:

我有一个简单的 ruby​​(非 Rails)应用程序,它使用 resque,如果没有 heroku 上的 config.ru,将无法启动。当我添加 config.ru 文件时,在本地运行 rackup 时出现以下错误:

/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:133:in `to_app': missing run or map statement (RuntimeError)
from /Users/nickkarrasch/Dropbox/Coding/Ruby/smsnotifyv2/config.ru:in `<main>'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p194/bin/rackup:23:in `load'
from /usr/local/Cellar/ruby/1.9.3-p194/bin/rackup:23:in `<main>'

我需要在 config.ru 中添加什么?

【问题讨论】:

    标签: ruby heroku rack resque


    【解决方案1】:

    该文件 (config.ru) 的内容将取决于您实际尝试执行的操作以及您使用的框架,因为它仅用于配置 Rack 应用程序,它告诉Rack::Builder 应该使用什么中间件以及使用顺序。这些是 Heroku 文档for deploying rack applications. 中提供的一些示例:

    辛纳特拉

    require './hello'
    run Sinatra::Application
    

    拉玛兹

    require ::File.expand_path('./../hello', __FILE__)
    Ramaze.start(:file => __FILE__, :started => true)
    run Ramaze
    

    露营

    require './hello'
    run Rack::Adapter::Camping.new(Hello)
    

    【讨论】:

      猜你喜欢
      • 2013-07-23
      • 2012-01-10
      • 2014-12-21
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多