【问题标题】:How to Specify One Worker on a Queue for Delayed Jobs如何在延迟作业的队列中指定一个工作人员
【发布时间】:2017-02-16 18:33:40
【问题描述】:

在使用延迟作业时,如何为特定队列指定一名工作人员?我知道我可以运行这个命令:

# Use the --pool option to specify a worker pool. You can use this option 
# multiple times to start different numbers of workers for different queues.
# The following command will start 1 worker for the tracking queue, 
# 2 workers for the mailers and tasks queues, and 2 workers for any jobs:

RAILS_ENV=production script/delayed_job --pool=tracking --pool=mailers,tasks:2 --pool=*:2 start

但是由于我们使用的是 heroku,所以我们使用了一个 procfile 来运行我们的工作人员:

worker: bundle exec foreman start -f Procfile.workers 和我们的工作文件运行作业:

worker_1: bundle exec rake jobs:work
worker_2: bundle exec rake jobs:work

然而,我想做的是:

bundle exec rake jobs:work --queue=specific_queue

并且只有一名工作人员在特定队列上工作,其他工作人员在其他队列上工作。

我怎样才能做到这一点?

【问题讨论】:

  • 我的回答对你有用吗?

标签: ruby-on-rails ruby heroku delayed-job


【解决方案1】:

如果您查看 Heroku 的 Process Types and the Procfile 文档,您会在末尾找到 this 示例:

例如,使用 Ruby,您可以运行两种类型的队列工作程序,每种 消耗不同的队列:

worker:        env QUEUE=* bundle exec rake resque:work
urgentworker:  env QUEUE=urgent bundle exec rake resque:work

Delayed Job 使用类似于 Resque 的东西。它使用环境变量 QUEUE 或 QUEUES 来指定特定工作人员的队列。

您可以在lib/delayed/tasks.rb source code 上验证。

【讨论】:

  • 确实如此。谢谢
  • @jwill worker: env QUEUE=* bundle exec rake resque:work 也会处理紧急队列吗?
猜你喜欢
  • 1970-01-01
  • 2011-08-26
  • 1970-01-01
  • 1970-01-01
  • 2017-02-23
  • 2013-09-04
  • 2017-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多