2

我正在关注 railscast 并完全按照说明进行操作。我什至使用net.tutsplus 的faye.ru 代码在根目录下设置了faye.ru 文件。

这是 faye.ru 文件:

require 'faye'
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server

当我尝试使用启动服务器时rackup faye.ru -s thin -E production

我收到以下错误:

/Users/TonyNg/faye-tutorial/faye.ru:3:in `block in <main>': undefined local variable or method ` ' for #<Rack::Builder:0x00000100918420 @ins=[]> (NameError)
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/TonyNg/faye-tutorial/faye.ru:1:in `new'
    from /Users/TonyNg/faye-tutorial/faye.ru:1:in `<main>'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/builder.rb:40:in `eval'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/server.rb:200:in `app'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/server.rb:252:in `start'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/lib/rack/server.rb:137:in `start'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/gems/rack-1.3.5/bin/rackup:4:in `<top (required)>'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/bin/rackup:19:in `load'
    from /Users/TonyNg/.rvm/gems/ruby-1.9.3-p0@rails313/bin/rackup:19:in `<main>'

它似乎只适用于瑞安,但我不走运。

4

1 回答 1

1

我找到了解决方案。我改为运行rackup -s thin -E production config.ruconfig.ru而不是 faye.ru)并获得了一个工作服务器,其中包括:

>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop

显然,Rack 的开发中间件不适用于 Thin 异步响应,因为我在此应用程序中使用 Thin。

于 2011-12-14T07:24:59.600 回答