5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-10-07 12:26:56 +00:00

Merge branch 'issue-10464' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-03-18 16:58:18 -03:00
commit ea7e58a3bf
8 changed files with 49 additions and 9 deletions

View file

@ -15,7 +15,9 @@ require 'njalla/v1'
class DeployDistributedPress < Deploy class DeployDistributedPress < Deploy
store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON 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 # Actualiza la información y luego envía los cambios
# #
@ -27,6 +29,14 @@ class DeployDistributedPress < Deploy
time_start 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| site_client.tap do |c|
stdout = Thread.new(publisher.logger_out) do |io| stdout = Thread.new(publisher.logger_out) do |io|
until io.eof? until io.eof?
@ -112,7 +122,16 @@ class DeployDistributedPress < Deploy
self.remote_site_id = created_site[:id] self.remote_site_id = created_site[:id]
self.remote_info = created_site.to_h 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 # XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
# que eliminarlo. # que eliminarlo.
unless site.name.end_with? '.' 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']['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 self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h
end end
rescue HTTParty::Error => e
ExceptionNotifier.notify_exception(e, data: { site: site.name })
self.remote_info['njalla'] = nil
ensure
nil nil
end end

View file

@ -19,4 +19,8 @@ class DeployFullRsync < DeployRsync
end end
end.flatten.all? end.flatten.all?
end end
def url
"https://#{user_host.last}/"
end
end end

View file

@ -3,7 +3,7 @@
# Sincroniza sitios a servidores remotos usando Rsync. El servidor # Sincroniza sitios a servidores remotos usando Rsync. El servidor
# remoto tiene que tener rsync instalado. # remoto tiene que tener rsync instalado.
class DeployRsync < Deploy 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] DEPENDENCIES = %i[deploy_local]
@ -25,8 +25,9 @@ class DeployRsync < Deploy
end end
end end
# @return [String]
def url def url
"https://#{user_host.last}" "https://#{hostname}/"
end end
private private

View file

@ -0,0 +1 @@
-# nada

View file

@ -0,0 +1 @@
-# nada

View file

@ -114,6 +114,10 @@ en:
title: Alternative domain name title: Alternative domain name
success: Success! success: Success!
error: Error error: Error
deploy_localized_domain:
title: Localized domain
success: Success!
error: Error
deploy_rsync: deploy_rsync:
title: Synchronize to backup server title: Synchronize to backup server
success: Success! success: Success!
@ -122,6 +126,10 @@ en:
title: Reindex title: Reindex
success: Success! success: Success!
error: Error error: Error
deploy_full_rsync:
title: Synchronize to another Sutty node
success: Success!
error: Error
deploy_distributed_press: deploy_distributed_press:
title: Distributed Web title: Distributed Web
success: Success! success: Success!

View file

@ -114,6 +114,10 @@ es:
title: Dominio alternativo title: Dominio alternativo
success: ¡Éxito! success: ¡Éxito!
error: Hubo un error error: Hubo un error
deploy_localized_domain:
title: Dominio por idioma
success: ¡Éxito!
error: Hubo un error
deploy_rsync: deploy_rsync:
title: Sincronizar al servidor alternativo title: Sincronizar al servidor alternativo
success: ¡Éxito! success: ¡Éxito!
@ -122,6 +126,10 @@ es:
title: Reindexación title: Reindexación
success: ¡Éxito! success: ¡Éxito!
error: Hubo un error error: Hubo un error
deploy_full_rsync:
title: Sincronizar a otro nodo de Sutty
success: ¡Éxito!
error: Hubo un error
deploy_distributed_press: deploy_distributed_press:
title: Web distribuida title: Web distribuida
success: ¡Éxito! success: ¡Éxito!

View file

@ -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" with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data"
every "0 3 * * *" every "0 3 * * *"
if status != 0 then alert 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