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
プール マネージャーが原因でプロセスをクラッシュさせるために何か間違ったことをしていますか?