Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you tell a specific Delayed::Job to run in console?

For some reason, Delayed::Job's has decided to queue up but not excecute anything even though I've restarted it several times, even kill -9'd it and restarted it. It won't run any jobs.

Can I , in /console, specify a specific job and tell it to work?

Ex:.. Delayed::Job.find(x).run

like image 818
Trip Avatar asked Aug 04 '11 17:08

Trip


People also ask

How do I run a delayed job?

script/delayed_job can be used to manage a background process which will start working off jobs. To do so, add gem "daemons" to your Gemfile and make sure you've run rails generate delayed_job . Workers can be running on any computer, as long as they have access to the database and their clock is in sync.

How do I find out if a job is delayed?

The most simple way to check whether delayed_job is running or not, is to check at locked_by field. This field will contain the worker or process locking/processing the job. Running Delayed::Job. where('locked_by is not null') will give you some results, if there are jobs running.


2 Answers

You can also do it like this:

Delayed::Worker.new.run( Delayed::Job.find(x) )  
like image 146
David Tuite Avatar answered Oct 08 '22 19:10

David Tuite


answering how to run specific job from console:

Delayed::Job.find(x).invoke_job

but you must remember that it won't run any other things like destroying job that was done or so on. just running the job/task.

like image 39
schiza Avatar answered Oct 08 '22 19:10

schiza