多个resque worker模式创建额外的进程

时间:2011-09-01 15:26:34

标签: resque

我需要启动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 

但是进入网络界面,它实际上是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] 

无法弄清楚导致额外流程启动的原因是什么?

1 个答案:

答案 0 :(得分: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.
与Resque一起运行多个进程的

Here's the example God monitoring/configuration filehere's an example for monit