gpt4 book ai didi

ruby - Ruby 守护进程中的错误文件描述符

转载 作者:数据小太阳 更新时间:2023-10-29 07:00:28 26 4
gpt4 key购买 nike

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

# config[:name] => 'idx_my_delete_consumer'# config[:daemon] => {:multiple => false,#                    :backtrace => true, #                    :dir_mode => :normal, #                    :log_dir => '/Users/pprakash/consumer.log',#                    :monitor => true,#                    :dir => '/Users/pprakash/pids'} Daemons.run_proc(config[:name], config[:daemon]) do    consumer = MyConsumer.new(config)      consumer.subscribe  end

但是,它并没有开始,而是抛出了一个长长的回溯,它是这样的:

E, [2012-05-28T19:34:16.199770 #29357] ERROR -- : Bad file descriptor (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:in `start_proc'/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/application.rb:295:in `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 `loop'/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:in `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:in `start_with_pidfile'/opt/local/lib/ruby/gems/1.8/gems/daemons-1.1.8/lib/daemons/monitor.rb:111:in `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:in `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:in `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:in `run_proc'users/delete_consumer.rb:40

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

最佳答案

根据我使用 Ruby 守护进程的经验,我发现此类错误表明底层 block (已守护进程)包含错误。修复这些错误也会修复此错误。

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com