我需要启动4个resque worker,所以我使用了以下命令
bundle exec rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid >> log/resque_worker_QUEUE.log
Run Code Online (Sandbox Code Playgroud)
但是去网络界面,它实际上是8个工人.有两个父进程,每个进程有4个子进程.以下是过程的树视图:
ruby /code_base/bundle/ruby/1.9.1/bin/rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid
\_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
\_ [ruby]
ruby /code_base/bundle/ruby/1.9.1/bin/rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid
\_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
| \_ [ruby]
\_ resque-1.15.0: Waiting for *
\_ [ruby]
无法弄清楚是什么导致了额外的流程启动?
Win*_*eld 13
您不希望在生产中使用COUNT = n选项,因为它在线程中运行每个工作程序而不是单独的进程 - 这不太稳定.
官方Resque文档:
Running Multiple Workers
At GitHub we use god to start and stop multiple workers. A sample god configuration file is included under examples/god. We recommend this method.
If you'd like to run multiple workers in development mode, you can do so using the resque:workers rake task:
$ COUNT=5 QUEUE=* rake resque:workers
This will spawn five Resque workers, each in its own thread. Hitting ctrl-c should be sufficient to stop them all.
Run Code Online (Sandbox Code Playgroud)
以下是 Resque附带的上帝监控/配置文件示例,用于运行多个进程,这是monit的示例.