Class: StepperMotor::ReapHungJourneysJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/stepper_motor/reap_hung_journeys_job.rb

Overview

The purpose of this job is to find journeys which have, for whatever reason, remained in the performing state for far longer than the journey is supposed to. At the moment it assumes any journey that stayed in performing for longer than 1 hour has hung. Add this job to your cron table and perform it regularly.

Instance Method Summary collapse

Instance Method Details

#performObject



6
7
8
9
10
11
# File 'lib/stepper_motor/reap_hung_journeys_job.rb', line 6

def perform
  StepperMotor::Journey.where("state = 'performing' AND updated_at < ?", 1.hour.ago).find_each do |hung_journey|
    hung_journey.update!(state: "ready")
    StepperMotor.scheduler.schedule(hung_journey)
  end
end