2021-09-01 02:09:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Environments
|
|
|
|
class AutoStopWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
|
|
|
data_consistency :always
|
|
|
|
idempotent!
|
|
|
|
feature_category :continuous_delivery
|
|
|
|
|
|
|
|
def perform(environment_id, params = {})
|
|
|
|
Environment.find_by_id(environment_id).try do |environment|
|
2022-04-14 02:08:29 -04:00
|
|
|
stop_actions = environment.stop_actions
|
|
|
|
|
|
|
|
user = stop_actions.last&.user
|
|
|
|
environment.stop_with_actions!(user)
|
2021-09-01 02:09:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|