2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
class PipelineScheduleService < BaseService
|
|
|
|
def execute(schedule)
|
|
|
|
# Ensure `next_run_at` is set properly before creating a pipeline.
|
|
|
|
# Otherwise, multiple pipelines could be created in a short interval.
|
|
|
|
schedule.schedule_next_run!
|
|
|
|
|
|
|
|
if Feature.enabled?(:ci_pipeline_schedule_async)
|
|
|
|
RunPipelineScheduleWorker.perform_async(schedule.id, schedule.owner&.id)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
RunPipelineScheduleWorker.new.perform(schedule.id, schedule.owner&.id)
|
|
|
|
ensure
|
|
|
|
##
|
|
|
|
# This is the temporary solution for avoiding the memory bloat.
|
2019-12-04 20:38:33 +05:30
|
|
|
# See more https://gitlab.com/gitlab-org/gitlab-foss/issues/61955
|
2019-09-04 21:01:54 +05:30
|
|
|
GC.start if Feature.enabled?(:ci_pipeline_schedule_force_gc, default_enabled: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|