diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index a94f7baf..dea651d9 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -15,7 +15,9 @@ require 'njalla/v1' class DeployDistributedPress < Deploy store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON - before_create :create_remote_site! + before_create :create_remote_site!, :create_njalla_records! + + DEPENDENCIES = %i[deploy_local] # Actualiza la información y luego envía los cambios # @@ -27,6 +29,14 @@ class DeployDistributedPress < Deploy time_start + create_remote_site! if remote_site_id.blank? + create_njalla_records! if remote_info['njalla'].blank? + save + + if remote_site_id.blank? || remote_info['njalla'].blank? + raise DeployJob::DeployException, '' + end + site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| until io.eof? @@ -112,7 +122,16 @@ class DeployDistributedPress < Deploy self.remote_site_id = created_site[:id] self.remote_info = created_site.to_h + rescue DistributedPress::V1::Error + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + ensure + nil + end + # Crea los registros en Njalla + # + # @return [nil] + def create_njalla_records! # XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay # que eliminarlo. unless site.name.end_with? '.' @@ -120,7 +139,10 @@ class DeployDistributedPress < Deploy self.remote_info['njalla']['a'] = njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h end - + rescue HTTParty::Error => e + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + self.remote_info['njalla'] = nil + ensure nil end diff --git a/app/models/deploy_full_rsync.rb b/app/models/deploy_full_rsync.rb index c0ff84c6..8f1d306e 100644 --- a/app/models/deploy_full_rsync.rb +++ b/app/models/deploy_full_rsync.rb @@ -19,4 +19,8 @@ class DeployFullRsync < DeployRsync end end.flatten.all? end + + def url + "https://#{user_host.last}/" + end end diff --git a/app/models/deploy_rsync.rb b/app/models/deploy_rsync.rb index 0020324c..f5d1bd9e 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -3,7 +3,7 @@ # Sincroniza sitios a servidores remotos usando Rsync. El servidor # remoto tiene que tener rsync instalado. class DeployRsync < Deploy - store :values, accessors: %i[destination host_keys], coder: JSON + store :values, accessors: %i[hostname destination host_keys], coder: JSON DEPENDENCIES = %i[deploy_local] @@ -25,8 +25,9 @@ class DeployRsync < Deploy end end + # @return [String] def url - "https://#{user_host.last}" + "https://#{hostname}/" end private diff --git a/app/views/deploys/_deploy_full_rsync.haml b/app/views/deploys/_deploy_full_rsync.haml new file mode 100644 index 00000000..0aab9802 --- /dev/null +++ b/app/views/deploys/_deploy_full_rsync.haml @@ -0,0 +1 @@ +-# nada diff --git a/app/views/deploys/_deploy_localized_domain.haml b/app/views/deploys/_deploy_localized_domain.haml new file mode 100644 index 00000000..0aab9802 --- /dev/null +++ b/app/views/deploys/_deploy_localized_domain.haml @@ -0,0 +1 @@ +-# nada diff --git a/config/locales/en.yml b/config/locales/en.yml index c69ed0d6..97a1588f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -114,6 +114,10 @@ en: title: Alternative domain name success: Success! error: Error + deploy_localized_domain: + title: Localized domain + success: Success! + error: Error deploy_rsync: title: Synchronize to backup server success: Success! @@ -122,6 +126,10 @@ en: 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! diff --git a/config/locales/es.yml b/config/locales/es.yml index 60dd063a..450071c0 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -114,6 +114,10 @@ es: title: Dominio alternativo success: ¡Éxito! error: Hubo un error + deploy_localized_domain: + title: Dominio por idioma + success: ¡Éxito! + error: Hubo un error deploy_rsync: title: Sincronizar al servidor alternativo success: ¡Éxito! @@ -122,6 +126,10 @@ es: title: Reindexación success: ¡Éxito! error: Hubo un error + deploy_full_rsync: + title: Sincronizar a otro nodo de Sutty + success: ¡Éxito! + error: Hubo un error deploy_distributed_press: title: Web distribuida success: ¡Éxito! diff --git a/monit.conf b/monit.conf index 3dee0b22..ebb27fe7 100644 --- a/monit.conf +++ b/monit.conf @@ -18,8 +18,3 @@ 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 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