diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index f49f465f..6da609cb 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -4,11 +4,22 @@ 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) @@ -23,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 = {} diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index adc6c9f6..339077bb 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -105,10 +105,6 @@ class DeployLocal < Deploy File.exist? yarn_lock end - def gem(output: false) - run %(gem install bundler --no-document), output: output - end - def pnpm_lock File.join(site.path, 'pnpm-lock.yaml') end @@ -124,6 +120,10 @@ class DeployLocal < Deploy run 'pnpm install --production', output: output end + def gem(output: false) + run %(gem install bundler --no-document), output: output + end + # Corre yarn dentro del repositorio def yarn(output: false) return true unless yarn_lock? diff --git a/config/initializers/que.rb b/config/initializers/que.rb index 579f57d5..d7abfeb5 100644 --- a/config/initializers/que.rb +++ b/config/initializers/que.rb @@ -4,5 +4,5 @@ ActiveJob::Serializers.add_serializers ActiveJob::Serializers::ExceptionSerializ # Notificar los errores Que.error_notifier = proc do |error, job| - ExceptionNotifier.notify_exception(error, data: job) + ExceptionNotifier.notify_exception(error, data: (job || {})) end diff --git a/config/locales/en.yml b/config/locales/en.yml index b819784f..32d44985 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,9 @@ en: ar: name: Arabic dir: rtl + ur: + name: Urdu + dir: rtl zh: name: Chinese dir: ltr @@ -24,9 +27,6 @@ en: fr: name: French dir: ltr - ur: - name: Urdu - dir: rtl login: email: E-mail address password: Password @@ -119,6 +119,14 @@ en: title: Alternative domain name success: Success! error: Error + deploy_distributed_press: + title: Distributed Web + success: Success! + error: Error + deploy_reindex: + title: Reindex + success: Success! + error: Error deploy_localized_domain: title: Domain name by language success: Success! @@ -127,18 +135,10 @@ en: title: Synchronize to backup server success: Success! error: Error - deploy_reindex: - title: Reindex - success: Success! - error: Error deploy_full_rsync: title: Synchronize to another Sutty node success: Success! error: Error - deploy_distributed_press: - title: Distributed Web - success: Success! - error: Error help: You can contact us by replying to this e-mail maintenance_mailer: notice: diff --git a/config/locales/es.yml b/config/locales/es.yml index 3738e268..dea62bfe 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -15,6 +15,9 @@ es: ar: name: Árabe dir: rtl + ur: + name: Urdu + dir: rtl zh: name: Chino dir: ltr @@ -24,9 +27,6 @@ es: fr: name: Francés dir: ltr - ur: - name: Urdu - dir: rtl login: email: Correo electrónico password: Contraseña @@ -119,6 +119,10 @@ es: title: Dominio alternativo success: ¡Éxito! error: Hubo un error + deploy_distributed_press: + title: Web distribuida + success: ¡Éxito! + error: Hubo un error deploy_localized_domain: title: Dominio según idioma success: ¡Éxito! @@ -135,10 +139,6 @@ es: title: Sincronizar a otro nodo de Sutty success: ¡Éxito! error: Hubo un error - deploy_distributed_press: - title: Web distribuida - success: ¡Éxito! - error: Hubo un error help: Por cualquier duda, responde este correo para contactarte con nosotres. maintenance_mailer: notice: diff --git a/monit.conf b/monit.conf index 91f4c25f..09574d0a 100644 --- a/monit.conf +++ b/monit.conf @@ -4,6 +4,11 @@ check program cleanup every "0 3 1 * *" if status != 0 then alert +check program distributed_press_tokens_renew + with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data" + every "0 3 * * *" + if status != 0 then alert + check program access_logs with path "/srv/bin/access_logs" as uid "rails" and gid "www-data" every "0 0 * * *" @@ -14,11 +19,6 @@ check program stats every "0 1 * * *" if status != 0 then alert -check program distributed_press_tokens_renew - with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data" - every "0 3 * * *" - if status != 0 then alert - check process que with pidfile /srv/tmp/que.pid start program = "/usr/bin/foreman run -f /srv/Procfile -d /srv que" stop program = "/bin/sh -c 'cat /srv/tmp/que.pid | xargs -r kill'"