多resque worker模式创建额外的进程 [英] Multiple resque workers mode creating extra processes
问题描述
我需要启动 4 个 resque 工人,所以我使用了以下命令
bundle exec rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid >>日志/resque_worker_QUEUE.log
但转到 Web 界面,它实际上启动了 8 个工人.有两个父进程,每个进程有 4 个子进程.以下是进程的树视图:
<前>ruby/code_base/bundle/ruby/1.9.1/bin/rake 环境 resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*\_ [红宝石]ruby/code_base/bundle/ruby/1.9.1/bin/rake 环境 resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*|\_ [红宝石]\_ resque-1.15.0:等待*\_ [红宝石]无法找出导致额外进程启动的原因?
您不希望在生产中使用 COUNT=n 选项,因为它在一个线程中运行每个 worker 而不是一个单独的进程 - 这要少得多稳定.
官方 Resque 文档:
运行多个工人在 GitHub,我们使用 God 来启动和停止多个 worker.示例 God 配置文件包含在 examples/god 下.我们推荐这种方法.如果你想在开发模式下运行多个 worker,你可以使用 resque:workers rake 任务来实现:$ COUNT=5 QUEUE=* rake resque:workers这将产生五个 Resque 工人,每个工人都在自己的过程中.按 ctrl-c 应该足以阻止它们.
这里是示例神监控/配置文件 与 Resque 一起运行以运行多个进程,并且 这里是一个示例监控.
I need to start 4 resque workers so i used following command
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
But going to web interface, it was actually starting 8 workers. There were two parent processes with 4 child processes each. Following is tree view of the processess:
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]
Couldn't figure out what is causing extra process to start?
You don't want to use the COUNT=n option in production, as it runs each worker in a thread instead of a separate process - which is much less stable.
Official Resque docs:
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 process. Hitting ctrl-c should be sufficient to stop them all.
Here's the example God monitoring/configuration file that ships with Resque to run multiple processes, and here's an example for monit.
这篇关于多resque worker模式创建额外的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!