简体   繁体   English

使用Resque的工作在Heroku上给出了“不知道如何构建任务'工作:工作'”

[英]Jobs with Resque gives “Don't know how to build task 'jobs:work'” on Heroku

I followed the tutorial at https://devcenter.heroku.com/articles/queuing-ruby-resque to queue and run background jobs in a Rails app. 我按照https://devcenter.heroku.com/articles/queuing-ruby-resque上的教程在Rails应用程序中排队并运行后台作业。 After queueing the jobs, it doesn't seem to run any of the jobs since in the console I can see the job has not been processed 排队作业后,似乎没有运行任何作业,因为在控制台中我可以看到作业尚未处理

>Resque.info
=> {:pending=>1, :processed=>0, :queues=>1, :workers=>0, :working=>0, :failed=>0, :servers=>["redis://dory.redistogo.com:9826/0"], :environment=>"production"}

If I try to do (locally) 如果我尝试(本地)

bundle exec rake jobs:work

I get 我明白了

rake aborted!
Don't know how to build task 'jobs:work'

On heroku, if I try 在heroku上,如果我尝试

heroku run rake jobs:work

I again get `Don't know how to build task' 我再次得到“不知道如何建立任务”

In my Rakefile, I have require 'resque/tasks' and in my Procfile I have 在我的Rakefile中,我require 'resque/tasks'并且在我的Procfile中我有

resque: env TERM_CHILD=1 bundle exec rake jobs:work
resque: env TERM_CHILD=1 bundle exec rake jobs:work

I have the Resque and redis gems in my Gemfile, but not delayed_job. 我的Gemfile中有Resque和redis宝石,但不是delayed_job。

Update: Here is my Rakefile: 更新:这是我的Rakefile:

#!/usr/bin/env rake
require File.expand_path('../config/application', __FILE__)
Guard::Application.load_tasks

/lib/tasks is empty. /lib/tasks是空的。 I have a worker in app/workers that I am enqueueing in a controller. 我有一个app / worker的工人,我在控制器中入队。

This doesn't appear to have anything to do with Heroku, if it doesn't work locally. 这似乎与Heroku没有任何关系,如果它不在本地工作。 You'll have to reveal some of your source to help people help you. 您必须透露一些来源以帮助人们为您提供帮助。 For example, what's your Rakefile look like? 例如,你的Rakefile是什么样的? The demo app in that article defines one with a Rake task with the task. 该文章中的演示应用程序定义了一个带有任务的Rake任务。 Have you defined your rake task and added the appropriate gem references? 您是否定义了rake任务并添加了相应的gem参考?

尝试resque:work而不是jobs:work ,看看是否会产生预期的结果。

You just need to add require 'resque/tasks' in your Rakefile , then on the command line: 您只需要在Rakefile添加Rakefile require 'resque/tasks' ,然后在命令行中:

QUEUE=file_serve rake environment resque:work

Where file_serve is the name of your job (the class would be FileServeJob ). 其中file_serve是您的作业名称(该类将是FileServeJob )。

See the docs here - I found them slightly confusing since the setup and run info comes after the job class creation. 请参阅此处的文档 - 我发现它们有点混乱,因为在创建作业类之后设置和运行信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM