mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 15:36:22 +00:00
Merge branch 'issue-10464' into panel.sutty.nl
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:
commit
ea7e58a3bf
8 changed files with 49 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -19,4 +19,8 @@ class DeployFullRsync < DeployRsync
|
|||
end
|
||||
end.flatten.all?
|
||||
end
|
||||
|
||||
def url
|
||||
"https://#{user_host.last}/"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
1
app/views/deploys/_deploy_full_rsync.haml
Normal file
1
app/views/deploys/_deploy_full_rsync.haml
Normal file
|
@ -0,0 +1 @@
|
|||
-# nada
|
1
app/views/deploys/_deploy_localized_domain.haml
Normal file
1
app/views/deploys/_deploy_localized_domain.haml
Normal file
|
@ -0,0 +1 @@
|
|||
-# nada
|
|
@ -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!
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue