mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 07:06:23 +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
|
||||
class DeployJob < ApplicationJob
|
||||
class DeployException < StandardError; end
|
||||
class DeployTimedOutException < DeployException; end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def perform(site, notify = true, time = Time.now)
|
||||
|
@ -16,8 +17,8 @@ class DeployJob < ApplicationJob
|
|||
# hora original para poder ir haciendo timeouts.
|
||||
if @site.building?
|
||||
if 10.minutes.ago >= time
|
||||
@site.update status: 'waiting'
|
||||
raise DeployException,
|
||||
notify = false
|
||||
raise DeployTimedOutException,
|
||||
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
||||
end
|
||||
|
||||
|
@ -37,18 +38,14 @@ class DeployJob < ApplicationJob
|
|||
}
|
||||
|
||||
# No es opcional
|
||||
unless @deployed[:deploy_local]
|
||||
@site.update status: 'waiting'
|
||||
notify_usuaries if notify
|
||||
|
||||
unless @deployed[:deploy_local][:status]
|
||||
# Hacer fallar la tarea
|
||||
raise DeployException, deploy_local.build_stats.last.log
|
||||
end
|
||||
|
||||
deploy_others
|
||||
|
||||
# Volver a la espera
|
||||
@site.update status: 'waiting'
|
||||
ensure
|
||||
@site&.update status: 'waiting'
|
||||
|
||||
notify_usuaries if notify
|
||||
end
|
||||
|
@ -67,12 +64,19 @@ class DeployJob < ApplicationJob
|
|||
|
||||
def deploy_others
|
||||
@site.deploys.where.not(type: 'DeployLocal').find_each do |d|
|
||||
begin
|
||||
status = d.deploy
|
||||
build_stat = d.build_stats.last
|
||||
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] = {
|
||||
status: status,
|
||||
seconds: build_stat.try(:seconds) || 0,
|
||||
seconds: seconds || 0,
|
||||
size: d.size,
|
||||
urls: d.respond_to?(:urls) ? d.urls : [d.url]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue