2017-03-29 07:49:47 -04:00
|
|
|
class TriggerScheduleWorker
|
2017-03-22 14:54:49 -04:00
|
|
|
include Sidekiq::Worker
|
|
|
|
include CronjobQueue
|
|
|
|
|
|
|
|
def perform
|
2017-04-07 08:47:29 -04:00
|
|
|
Ci::TriggerSchedule.active.where("next_run_at < ?", Time.now).find_each do |trigger_schedule|
|
2017-03-22 14:54:49 -04:00
|
|
|
begin
|
2017-03-30 07:59:20 -04:00
|
|
|
Ci::CreateTriggerRequestService.new.execute(trigger_schedule.project,
|
2017-03-29 09:14:58 -04:00
|
|
|
trigger_schedule.trigger,
|
2017-03-30 07:59:20 -04:00
|
|
|
trigger_schedule.ref)
|
2017-03-22 14:54:49 -04:00
|
|
|
rescue => e
|
2017-03-29 09:14:58 -04:00
|
|
|
Rails.logger.error "#{trigger_schedule.id}: Failed to trigger_schedule job: #{e.message}"
|
2017-03-22 14:54:49 -04:00
|
|
|
ensure
|
2017-03-29 09:14:58 -04:00
|
|
|
trigger_schedule.schedule_next_run!
|
2017-03-22 14:54:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|