【发布时间】:2011-11-30 13:28:17
【问题描述】:
我正在尝试设置我的环境以让 Rails、EventMachine 和 async_sinatra 一起玩,我想我的设置有误,因为我收到错误“未捕获的 throw :async”。
这是我的 Gemfile 中的内容:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'sinatra'
gem 'async_sinatra'
gem 'execjs'
gem 'therubyracer'
gem 'eventmachine'
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
gem 'thin'
这是 config.ru:
require ::File.expand_path('../config/environment', __FILE__)
use Rack::FiberPool
run Longpoll::Application
这是我在 routes.rb 文件中的内容:
match '/longpoll', :to => LongPoll
这是我的 long_poll.rb 文件:
class LongPoll < Sinatra::Base
register Sinatra::Async
aget '/longpoll' do
body 'Hello world!'
end
end
任何想法我缺少什么让这个设置工作?
编辑:
我发现不使用 rack-fiber_pool 可以解决问题。 谁能确认他们是否可以一起工作?
另一个给出相同错误basic.ru的例子:
#!/usr/bin/env rackup -Ilib:../lib -s thin
require 'sinatra/async'
require 'rack/fiber_pool'
class AsyncTest < Sinatra::Base
register Sinatra::Async
use Rack::FiberPool
enable :show_exceptions
aget '/' do
body "hello async"
end
end
run AsyncTest.new
【问题讨论】:
标签: ruby-on-rails sinatra eventmachine thin