mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 11:26:22 +00:00
Merge branch 'issue-10031' into informative-deploys
This commit is contained in:
commit
87f37ae39e
1 changed files with 16 additions and 12 deletions
|
@ -3,6 +3,7 @@
|
||||||
# Realiza el deploy de un sitio
|
# Realiza el deploy de un sitio
|
||||||
class DeployJob < ApplicationJob
|
class DeployJob < ApplicationJob
|
||||||
class DeployException < StandardError; end
|
class DeployException < StandardError; end
|
||||||
|
class DeployTimedOutException < DeployException; end
|
||||||
|
|
||||||
# rubocop:disable Metrics/MethodLength
|
# rubocop:disable Metrics/MethodLength
|
||||||
def perform(site, notify = true, time = Time.now)
|
def perform(site, notify = true, time = Time.now)
|
||||||
|
@ -16,8 +17,8 @@ class DeployJob < ApplicationJob
|
||||||
# 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
|
if 10.minutes.ago >= time
|
||||||
@site.update status: 'waiting'
|
notify = false
|
||||||
raise DeployException,
|
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"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,18 +38,14 @@ class DeployJob < ApplicationJob
|
||||||
}
|
}
|
||||||
|
|
||||||
# No es opcional
|
# No es opcional
|
||||||
unless @deployed[:deploy_local]
|
unless @deployed[:deploy_local][:status]
|
||||||
@site.update status: 'waiting'
|
|
||||||
notify_usuaries if notify
|
|
||||||
|
|
||||||
# Hacer fallar la tarea
|
# Hacer fallar la tarea
|
||||||
raise DeployException, deploy_local.build_stats.last.log
|
raise DeployException, deploy_local.build_stats.last.log
|
||||||
end
|
end
|
||||||
|
|
||||||
deploy_others
|
deploy_others
|
||||||
|
ensure
|
||||||
# Volver a la espera
|
@site&.update status: 'waiting'
|
||||||
@site.update status: 'waiting'
|
|
||||||
|
|
||||||
notify_usuaries if notify
|
notify_usuaries if notify
|
||||||
end
|
end
|
||||||
|
@ -67,12 +64,19 @@ class DeployJob < ApplicationJob
|
||||||
|
|
||||||
def deploy_others
|
def deploy_others
|
||||||
@site.deploys.where.not(type: 'DeployLocal').find_each do |d|
|
@site.deploys.where.not(type: 'DeployLocal').find_each do |d|
|
||||||
status = d.deploy
|
begin
|
||||||
build_stat = d.build_stats.last
|
status = d.deploy
|
||||||
|
seconds = d.build_stats.last.try(:seconds)
|
||||||
|
rescue StandardError => e
|
||||||
|
status = false
|
||||||
|
seconds = 0
|
||||||
|
|
||||||
|
ExceptionNotifier.notify_exception(e, data: { site: site.id, deploy: d.type })
|
||||||
|
end
|
||||||
|
|
||||||
@deployed[d.type.underscore.to_sym] = {
|
@deployed[d.type.underscore.to_sym] = {
|
||||||
status: status,
|
status: status,
|
||||||
seconds: build_stat.try(:seconds) || 0,
|
seconds: seconds || 0,
|
||||||
size: d.size,
|
size: d.size,
|
||||||
urls: d.respond_to?(:urls) ? d.urls : [d.url]
|
urls: d.respond_to?(:urls) ? d.urls : [d.url]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue