5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 08:21:41 +00:00

fix: retomar la publicación de cambios #12958
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-04-10 13:28:32 -03:00
parent 20e8e83ab6
commit a58936b22e

View file

@ -4,9 +4,23 @@
class DeployJob < ApplicationJob
class DeployException < StandardError; end
class DeployTimedOutException < DeployException; end
class DeployAlreadyRunningException < DeployException; end
discard_on ActiveRecord::RecordNotFound
# Lanzar lo antes posible
self.priority = 10
# Intentar dentro de un minuto
self.retry_interval = 60
def handle_error(error)
case error
when DeployAlreadyRunningException then retry_in 1.minute
when DeployTimedOutException then expire
else super
end
end
# rubocop:disable Metrics/MethodLength
def perform(site, notify: true, time: Time.now, output: false)
@output = output
@ -20,14 +34,14 @@ class DeployJob < ApplicationJob
# Como el trabajo actual se aplaza al siguiente, arrastrar la
# hora original para poder ir haciendo timeouts.
if @site.building?
notify = false
if 10.minutes.ago >= time
notify = false
raise DeployTimedOutException,
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
else
raise DeployAlreadyRunningException
end
DeployJob.perform_in(60, site, notify: notify, time: time, output: output)
return
end
@deployed = {}
@ -67,8 +81,6 @@ class DeployJob < ApplicationJob
t << ([type.to_s] + row.values)
end
end)
rescue DeployTimedOutException => e
notify_exception e
ensure
if @site.present?
@site.update status: 'waiting'