运行 rake 任务以在 Heroku 上启动 Resque 工作线程

发布于 2024-11-29 18:03:29 字数 618 浏览 3 评论 0原文

因此,我在 Heroku 上设置了 Resque 和 redis,这就是我的 resque.rake 文件的样子:

require 'resque/tasks'

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'
end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

我运行了 heroku rake jobs:work 并让一名工作人员运行。这非常有效。我的后台工作正在完成。

然后我对代码做了一些更改,推送到heroku,仍然看到有一个工作线程在运行。然而,当作业被添加到队列中时,工作人员没有收到任何作业。所以我再次运行 heroku rake jobs:work ,它说我有两个工作人员正在运行,并且我的工作正在完成。

我的问题是为什么会发生这种情况?我每次推送到heroku 时都需要运行这个rake 任务吗?有没有办法自动执行此操作?另外,虽然我有两个工人在运行,但似乎只有一个在工作。有没有办法回到一个工人那里?

So I have Resque and redis to go set up on Heroku and this is what my resque.rake file looks like:

require 'resque/tasks'

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'
end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

I ran heroku rake jobs:work and got one worker running. This worked perfectly. My background jobs were being completed.

Then I made some changes in my code, pushed to heroku, and still saw that I had one worker running. However, while jobs were being added to the queue, the worker was not receiving any jobs. So I ran heroku rake jobs:work again, it said I had two workers running, and my jobs were being completed.

My question is why did this happen? Do I need to run this rake task every time I push to heroku? Is there a way to automate this? Also, although I have two workers running, there seems to be only one that is working. Is there a way to get back to one worker?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹂绝世的画 2024-12-06 18:03:29

您应该使用 Procfile 在 heroku http://devcenter.heroku.com/articles/procfile

请记住,Procfile 用于新的 Heroku Cedar Stack。

You should use Procfile for resque jobs on heroku http://devcenter.heroku.com/articles/procfile

Keep in mind that Procfile is used on new Heroku Cedar Stack.

难理解 2024-12-06 18:03:29

Resque 只需要一名工人。您需要运行 heroku rake jobs:work 或使用 Resque-Scheduler (cron,或运行该任务的东西)来自动运行您的作业。

You only need one worker for Resque. You will need to run heroku rake jobs:work or use Resque-Scheduler (cron, or something to run that task) to to automatically run your jobs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文