简体   繁体   中英

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. 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 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

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.

Update: Here is my Rakefile:

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

/lib/tasks is empty. I have a worker in app/workers that I am enqueueing in a controller.

This doesn't appear to have anything to do with Heroku, if it doesn't work locally. You'll have to reveal some of your source to help people help you. For example, what's your Rakefile look like? The demo app in that article defines one with a Rake task with the task. Have you defined your rake task and added the appropriate gem references?

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

You just need to add require 'resque/tasks' in your Rakefile , then on the command line:

QUEUE=file_serve rake environment resque:work

Where file_serve is the name of your job (the class would be FileServeJob ).

See the docs here - I found them slightly confusing since the setup and run info comes after the job class creation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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