我正在使用 Ruby 1.9.3,并在 Mac OSX 10.7 上对其进行测试。
我有一个Sender
应该向某个 URL 发送请求的类:
require "celluloid"
require "curb"
class Sender
include Celluloid
def send(msg)
Curl.get($URL) do |url|
url.headers["content-type"] = "text/html;charset=utf-8"
end
rescue Exception => e
$LOG.error "[erro]-> [ #{e.message} "
end
end
我有另一个进程应该从 RabbitMQ 队列接收消息并使用以下方式发送请求Sender
:
AMQP.start(:host => $AMQP_URL) do |connection|
@channel ||= AMQP::Channel.new(connection)
@queue ||= @channel.queue("results")
pool = Sender.pool
@queue.subscribe do |metadata, body|
msg = MessagePack.unpack(body)
pool.send(msg)
end
end
当我运行它时,我得到:
15:56:59 results.1 | I, [2013-02-12T15:56:59.422192 #44490] INFO -- : Terminating 5 actors...
15:56:59 results.1 | E, [2013-02-12T15:56:59.422640 #44490] ERROR -- : Celluloid::PoolManager crashed!
15:56:59 results.1 | NoMethodError: undefined method `each' for nil:NilClass
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/macosx.rb:39:in `<top (required)>'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:81:in `load'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:81:in `load_file'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:43:in `block (2 levels) in load_all'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:38:in `each'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:38:in `block in load_all'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:35:in `each'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:35:in `load_all'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/collection.rb:72:in `fact'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter.rb:94:in `block (2 levels) in singletonclass'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid.rb:37:in `cores'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/pool_manager.rb:12:in `initialize'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/calls.rb:57:in `dispatch'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/actor.rb:323:in `block in handle_message'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/tasks/task_fiber.rb:22:in `block in initialize'
15:56:59 results.1 | E, [2013-02-12T15:56:59.423117 #44490] ERROR -- : Celluloid::PoolManager#finalize crashed!
15:56:59 results.1 | NoMethodError: undefined method `+' for nil:NilClass
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/pool_manager.rb:26:in `finalize'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/actor.rb:376:in `block in run_finalizer'
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/tasks/task_fiber.rb:22:in `block in initialize'
15:56:59 results.1 | I, [2013-02-12T15:56:59.424508 #44490] INFO -- : Shutdown completed cleanly
15:56:59 results.1 | /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/macosx.rb:39:in `<top (required)>': undefined method `each' for nil:NilClass (NoMethodError)
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:81:in `load'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:81:in `load_file'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:43:in `block (2 levels) in load_all'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:38:in `each'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:38:in `block in load_all'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:35:in `each'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/loader.rb:35:in `load_all'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter/util/collection.rb:72:in `fact'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/facter-1.6.13/lib/facter.rb:94:in `block (2 levels) in singletonclass'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid.rb:37:in `cores'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/pool_manager.rb:12:in `initialize'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/calls.rb:57:in `dispatch'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/actor.rb:323:in `block in handle_message'
15:56:59 results.1 | from /Users/info/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.12.3/lib/celluloid/tasks/task_fiber.rb:22:in `block in initialize'
15:56:59 results.1 | exited with code 1
由于池管理器,我做错了什么导致进程崩溃吗?