Ruby-on-rails Sidekiq 作业卡在排队中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17204826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:11:51  来源:igfitidea点击:

Sidekiq jobs stuck in enqueue

ruby-on-railsruby-on-rails-3redisubuntu-10.04sidekiq

提问by groffcole

Sidekiq has been working in development mode just perfectly. Now that I am trying to use it in production, all the jobs are just sitting in enqueue and aren't ever being run. Could anyone point me in the right direction as to how to solve this issue?

Sidekiq 一直在完美的开发模式下工作。现在我正试图在生产中使用它,所有的工作都只是坐在排队中,永远不会运行。谁能指出我如何解决这个问题的正确方向?

采纳答案by cthulhu

Please check if sidekiq process is actually running:

请检查 sidekiq 进程是否实际运行:

ps aux | grep sidekiq

If it is not, try to run sidekiq in foreground first and check the output.

如果不是,请尝试先在前台运行 sidekiq 并检查输出。

bundle exec sidekiq -e production

回答by paascal

In many cases for me it's because I haven't properly declared the queue for this specific service in config/sidekiq.yml.

在很多情况下,对我来说这是因为我没有在config/sidekiq.yml.

回答by slindsey3000

Just a heads up to all as I ended up this page trying to figure out why my Rails Sidkiq jobs were not moving off 'enqueued'.

当我结束这个页面试图弄清楚为什么我的 Rails Sidkiq 工作没有“排队”时,只是提醒所有人。

  1. Check your sidekiq console in your terminal
  2. My issue which messed me up for almost an hour... duh... I had a 'byebug' breakpointin the code that is silly to put in a background job. This will totally foul your job up. Obviously... I didn't mean to put that breakpoint there. I swear :)
  1. 检查终端中的 sidekiq 控制台
  2. 我的问题让我搞砸了将近一个小时......呃......我在代码中有一个'byebug'断点,放在后台工作中很愚蠢。这将完全破坏你的工作。显然……我不是故意把断点放在那里的。我发誓 :)

回答by ChrisPhoenix

This answer looks relevant: Sidekiq not processing queueIf Sidekiq isn't told about the config file (which may require a different incantation in production) then it may not be using the right queue.

这个答案看起来很相关: Sidekiq not processing queue如果 Sidekiq 没有被告知配置文件(在生产中可能需要不同的咒语),那么它可能没有使用正确的队列。

回答by Joseph Combs

My solution:

我的解决方案:

1.) Look at the Sidekiq Web UIfor your app (this is where you can see the fact that jobs are getting into an enqueued state).

1.) 查看您的应用程序的Sidekiq Web UI(在这里您可以看到作业进入排队状态的事实)。

2.) Manually retry a failed job

2.) 手动重试失败的作业

3.) Inspect logs on the server running Sidekiq:

3.) 检查运行 Sidekiq 的服务器上的日志:

(generally this is where the log will be located, if say you are doing this on staging)

(通常这是日志所在的位置,如果说您在登台时这样做)

tail -f /var/www/yourappname/current/log/staging.log

This is generally where you will see a more detailed error message of why Sidekiq cannot process enqueued jobs. In our case, there was an environment variable pointing to an incorrect endpoint specific to our deployment configuration.

通常,您会在此处看到更详细的错误消息,说明为什么 Sidekiq 无法处理排队的作业。在我们的例子中,有一个环境变量指向特定于我们的部署配置的错误端点。

回答by Shimaa Marzouk

Using capistrano-sidekiqgem solved our problem

使用capistrano-sidekiqgem 解决了我们的问题

回答by yohanes

Make sure your app sidekiq process run

确保您的应用 sidekiq 进程运行

$ ps aux | grep sidekiq
server   26813  0.0  0.0  14228  1084 pts/11   S+   11:27   0:00 grep --color=auto sidekiq
server   27936  0.3  0.6 1178904 153240 ?      Sl   Apr17  46:02 sidekiq 5.2.7 app1 [0 of 10 busy]

The example show that there is only one sidekiq process running (app1). If your app not in the list, then you have to start sidekiq process for your app, in this example app2 . gem capistrano-sidekiqmake your life easier:

该示例显示只有一个 sidekiq 进程在运行(app1)。如果您的应用不在列表中,那么您必须为您的应用启动 sidekiq 进程,在本例中为 app2 。gemcapistrano-sidekiq让您的生活更轻松:

$ cap production sidekiq:start
00:00 sidekiq:start
      01 $HOME/.rbenv/bin/rbenv exec bundle exec sidekiq --index 0 --pidfile /var/www/app2/shared/tmp/pids/sidekiq-0.pid --environment produ…
    ? 01 [email protected] 0.400s

and the app2 process will be activated. Now, check again

并且 app2 进程将被激活。现在,再次检查

$ ps aux | grep sidekiq
server   25857  8.6  7.6 3073532 1870244 ?     Sl   11:15   1:02 sidekiq 5.2.8 app2 [0 of 10 busy]
server   26813  0.0  0.0  14228  1084 pts/11   S+   11:27   0:00 grep --color=auto sidekiq
server   27936  0.3  0.6 1178904 153240 ?      Sl   Apr17  46:02 sidekiq 5.2.7 app1 [0 of 10 busy]

the queue should have been running normally

队列应该正常运行