mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 12:51:42 +00:00
fix: retomar la publicación de cambios #12958
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
20e8e83ab6
commit
a58936b22e
1 changed files with 18 additions and 6 deletions
|
@ -4,9 +4,23 @@
|
||||||
class DeployJob < ApplicationJob
|
class DeployJob < ApplicationJob
|
||||||
class DeployException < StandardError; end
|
class DeployException < StandardError; end
|
||||||
class DeployTimedOutException < DeployException; end
|
class DeployTimedOutException < DeployException; end
|
||||||
|
class DeployAlreadyRunningException < DeployException; end
|
||||||
|
|
||||||
discard_on ActiveRecord::RecordNotFound
|
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
|
# rubocop:disable Metrics/MethodLength
|
||||||
def perform(site, notify: true, time: Time.now, output: false)
|
def perform(site, notify: true, time: Time.now, output: false)
|
||||||
@output = output
|
@output = output
|
||||||
|
@ -20,14 +34,14 @@ class DeployJob < ApplicationJob
|
||||||
# Como el trabajo actual se aplaza al siguiente, arrastrar la
|
# Como el trabajo actual se aplaza al siguiente, arrastrar la
|
||||||
# hora original para poder ir haciendo timeouts.
|
# hora original para poder ir haciendo timeouts.
|
||||||
if @site.building?
|
if @site.building?
|
||||||
if 10.minutes.ago >= time
|
|
||||||
notify = false
|
notify = false
|
||||||
|
|
||||||
|
if 10.minutes.ago >= time
|
||||||
raise DeployTimedOutException,
|
raise DeployTimedOutException,
|
||||||
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
||||||
|
else
|
||||||
|
raise DeployAlreadyRunningException
|
||||||
end
|
end
|
||||||
|
|
||||||
DeployJob.perform_in(60, site, notify: notify, time: time, output: output)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@deployed = {}
|
@deployed = {}
|
||||||
|
@ -67,8 +81,6 @@ class DeployJob < ApplicationJob
|
||||||
t << ([type.to_s] + row.values)
|
t << ([type.to_s] + row.values)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
rescue DeployTimedOutException => e
|
|
||||||
notify_exception e
|
|
||||||
ensure
|
ensure
|
||||||
if @site.present?
|
if @site.present?
|
||||||
@site.update status: 'waiting'
|
@site.update status: 'waiting'
|
||||||
|
|
Loading…
Reference in a new issue