我试图在Mac OS X Lion上使用Ruby v1.8.7和Daemons v1.1.8,试图编写一个使用者进程并使它作为dameon运行:

#config [:name] =>'idx_my_delete_consumer'
#config [:daemon] => {:multiple => false,
#:backtrace => true,
#:dir_mode =>:normal,
#:log_dir =>'/Users/pprakash/consumer.log',
#:显示器=>是的,
#:dir =>'/Users/pprakash/pids'}

Daemons.run_proc(config [:name],config [:daemon])做
消费者= MyConsumer.new(配置)
消费者订阅
结尾

但是,它没有启动,而是引发了长时间的追溯,如下所示:

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:在`for_fd'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:在`close_io'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:在'initialize'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:在'new'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:134:在`close_io'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/daemonize.rb:75:在`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:在'开始'中
/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:在'fork'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:51:在“监视”中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:45:在`each'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:45:在'watch'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:44:在`loop'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:44:在'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:在'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:在'开始'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application_group.rb:149:在`create_monitor'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application.rb:284:在'开始'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/controller.rb:70:在`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:在`call'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/cmdline.rb:109:在`catch_exceptions'中
/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons.rb:196:在`run_proc'中
users/delete_consumer.rb:40

我不确定是什么引起了这个问题?目录名,日志文件名均有效。我能够使用这些配置创建MyConsumer的实例,并能够从独立程序/控制台正确执行其#subscribe。

最佳答案

根据我对Ruby Daemon的经验,我发现此类错误表明基础块(已被守护)包含错误。修复这些错误也可以修复此错误。

关于ruby - Ruby守护程序中的错误文件描述符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10785992/

10-11 03:02