amitree / delayed_job_recurring

Extends delayed_job to support recurring jobs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Job is not recurring

opened this issue · comments

I've defined a job along the lines of:

class HealthCheckTask
  include Delayed::RecurringJob

  run_every 5.minutes
  ...

And schedule it with:

HealthCheckTask.schedule!

But it only executes once. Any suggestions as to why?

Try inheriting instead of including.

Thanks Jonathon, I'll give it a try. Is this dependent on ActiveJob version?

On 27 Oct 2016 9:32 pm, "Jonathan Aizen" notifications@github.com wrote:

Try inheriting instead of including.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKVYUadnpL6VIyR0DlBIB02CSJurHD0ks5q4JnJgaJpZM4KiGgR
.

Now that I look at our code, I see we do it like this:

module Recurring
  class SomeClass
    include Delayed::RecurringJob

So including is the right way to go. I'm not sure why it is only executing once for you. After it executes, do you see the newly created Delayed::Job in your database or not?

When I schedule it the first time I see it, but after it executes one it
doesn't seem to reschedule itself (doesn't appear in the table again).

On 28 Oct 2016 7:10 am, "Jonathan Aizen" notifications@github.com wrote:

Now that I look at our code, I see we do it like this:

module Recurring
class SomeClass
include Delayed::RecurringJob

So including is the right way to go. I'm not sure why it is only executing
once for you. After it executes, do you see the newly created Delayed::Job
in your database or not?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKVYfZFLe_sOb-vY_UJE8GMelOVxbCrks5q4SFAgaJpZM4KiGgR
.

I'm possibly experiencing this issue.

As an update to the information above, If I execute rails restart it does not update the schedule of the jobs.

Can you try with the latest version of the gem? (0.3.6)

If you're still having issues, what version of delayed_job and delayed_job_active_record are you using?

After a lot of work in the meantime (unsurprising, given the amount of time passed), I think I have a different issue.

FWIW, I'm currently using 0.3.6.

I'm having exactly this issue. i have a class like the following:

class `NightlyBatchJobs`
    include Delayed::RecurringJob
    run_every 1.day
    run_at '03:30pm'
    timezone 'US/Pacific'
    queue 'nightly'
    def perform
...
    end

I have a rake task (as suggested) that I run at deployment time to schedule the jobs.
A record gets put in the delayed_jobs table, and the job executes once. But afterwards, there is no longer a record in the table and the job does not execute again. I was using 0.3.5, but just upgraded to 0.3.6. delayed_job 4.1.1 and delayed_job_active_record 4.1.0.
Here's what the handler in the db looks like:
--- !ruby/object:NightlyBatchJobs
schedule_options:
:run_at:

  • 2017-10-27 21:04:06.768400000 Z
    :timezone: US/Pacific
    :run_interval:
    :value: 300
    :parts:
      • :seconds
      • 300
        :priority:
        :queue: nightly

(that's with the parameters updated to an every 5 minutes run of the job so I could try to figure out what is going on).

Let me see if I can reproduce this issue. Can you share your entire NightlyBatchJobs class? (Or better yet, replace the body of the perform method with something simple, like puts "hello", and confirm that it's still failing to reschedule the job)

Ah, I see what's happening. Delayed::RecurringJob reschedules itself in the success and failure methods, so overriding these methods prevents rescheduling.

There may be a better way to handle this, but for now, if you define success or failure, you'll need to call super.