Mac OS X Lion で Ruby v1.8.7 と Daemons v1.1.8 を使用して、コンシューマー プロセスを作成し、デーモンとして実行しようとしています。
# config[:name] => 'idx_my_delete_consumer' # config[:daemon] => {:multiple => false, # :バックトレース => true, # :dir_mode => :ノーマル, # :log_dir => '/Users/pprakash/consumer.log', # :モニター => true, # :dir => '/Users/pprakash/pids'} Daemons.run_proc(config[:name], config[:daemon]) do 消費者 = MyConsumer.new(config) consumer.subscribe 終わり
ただし、開始せず、代わりに次のような長いトレースバックをスローします。
E, [2012-05-28T19:34:16.199770 #29357] エラー -- : 不正なファイル記述子 (Errno::EBADF) /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:in `for_fd' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:in `close_io' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:in `initialize' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:in `new' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:in `close_io' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:75:in `call_as_daemon' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application.rb:258:`start_proc'内 /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application.rb:295:`start' で /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:51:in `watch' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:51:in `fork' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:51:in `watch' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:45:in `each' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:45:in `watch' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:44:in `ループ' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:44:in `watch' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:84:`start_with_pidfile' 内 /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:64:in `fork' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:64:`start_with_pidfile' 内 /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:111:`start' で /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application_group.rb:149:in `create_monitor' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application.rb:284:`start' で /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/controller.rb:70:in `run' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons.rb:197:`run_proc'内 /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/cmdline.rb:109:in `call' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/cmdline.rb:109:in `catch_exceptions' /opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons.rb:196:`run_proc'内 ユーザー/delete_consumer.rb:40
この問題の原因がわかりません。ディレクトリ名、ログファイル名はすべて有効です。これらの構成で MyConsumer のインスタンスを作成し、その #subscribe をスタンドアロン プログラム/コンソールから適切に実行できます。