本文介绍了Sidekiq 不处理队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sidekiq 有哪些可能的原因会阻止处理队列中的作业?队列已满.日志文件 sidekiq.log 表明根本没有活动.因此队列已满但日志为空,Sidekiq 似乎不处理项目.似乎没有工人处理工作.重新启动 Redis 或使用 FLUSHALLFLUSHDB 没有效果.Sidekiq 已经开始使用

What possible reasons can Sidekiq prevent from processing jobs in the queue? The queue is full. The log file sidekiq.log indicates no activity at all. Thus the queue is full but the log is empty, and Sidekiq does not seem to process items. There seem to no worker processing jobs. Restarting Redis or flush it with FLUSHALL or FLUSHDB as no effect. Sidekiq has been started with

bundle exec sidekiq -L log/sidekiq.log

并生成以下日志文​​件:

and produces the following log file:

2013-05-30..Booting Sidekiq 2.12.0 using redis://localhost:6379/0 with options {}
2013-05-30..Running in ruby 1.9.3p374 (2013-01-15 revision 38858) [i686-linux]
2013-05-30..See LICENSE and the LGPL-3.0 for licensing details.
2013-05-30..Starting processing, hit Ctrl-C to stop

你怎么能找出哪里出了问题?是否有隐藏的日志文件?

How can you find out what went wrong? Are there any hidden log files?

推荐答案

原因是在我们的例子中:Sidekiq 可能会查找错误的队列.默认情况下,Sidekiq 使用名为default"的队列.我们使用了两个不同的队列名称,并在 config/sidekiq.yml 中定义了它们

The reason was in our case: Sidekiq may look for the wrong queue. By default Sidekiq uses a queue named "default". We used two different queue names, and defined them in config/sidekiq.yml

# configuration file for Sidekiq
:queues:
  - queue_name_1
  - queue_name_2

问题是这个配置文件不会在您的开发环境中默认自动加载(与database.ymlthinking_sphinx.yml不同)例如)通过一个简单的 bundle exec sidekiq 命令.因此,我们在两个特定队列中编写了我们的作业,而 Sidekiq 正在等待第三个队列(默认队列)中的作业.您必须通过 -C--config 选项将配置文件的路径作为参数传递:

The problem is that this config file is not automatically loaded by default in your development environment (unlike database.yml or thinking_sphinx.yml for instance) by a simple bundle exec sidekiq command. Thus we wrote our jobs in two certain queues, and Sidekiq was waiting for jobs in a third queue (the default one). You have to pass the path to the config file as a parameter through the -Cor --config option:

bundle exec sidekiq -C ./config/sidekiq.yml

或者你可以直接传递队列名称(逗号后不允许有空格):

or you can pass the queue names directly (no spaces allowed here after the comma):

bundle exec sidekiq -q queue_name_1,queue_name_2

要找出问题,在命令行中传递选项 -v--verbose 或使用 :verbose 会很有帮助: truesidekiq.yml 文件中.如果没有加载配置文件,那么在配置文件中定义的所有内容当然都是无用的.因此,请确保首先使用正确的配置文件.

To find the problem out it is helpful to pass the option -v or --verbose at the command line, too, or to use :verbose: true in the sidekiq.yml file. Everything which is defined in a config file is of course useless if the config file is not loaded.. Therefore make sure you are using the right config file first.

这篇关于Sidekiq 不处理队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:25