Class: StepperMotor::RecoverStuckJourneysJobV1

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/stepper_motor/recover_stuck_journeys_job_v1.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.

Constant Summary collapse

DEFAULT_STUCK_FOR =
2.days

Instance Method Summary collapse

Instance Method Details

#perform(stuck_for: DEFAULT_STUCK_FOR) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/stepper_motor/recover_stuck_journeys_job_v1.rb', line 12

def perform(stuck_for: DEFAULT_STUCK_FOR)
  StepperMotor::Journey.stuck(stuck_for.ago).find_each do |journey|
    journey.recover!
  rescue => e
    Rails&.error&.report(e)
  end
end