mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 18:36:22 +00:00
feat: separar la creación de DP de njalla
This commit is contained in:
parent
2b340a4488
commit
29e1d09986
1 changed files with 14 additions and 6 deletions
|
@ -15,7 +15,7 @@ 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!
|
||||||
|
|
||||||
# Actualiza la información y luego envía los cambios
|
# Actualiza la información y luego envía los cambios
|
||||||
#
|
#
|
||||||
|
@ -27,10 +27,9 @@ class DeployDistributedPress < Deploy
|
||||||
|
|
||||||
time_start
|
time_start
|
||||||
|
|
||||||
if remote_site_id.blank? || remote_info['njalla'].blank?
|
create_remote_site! if remote_site_id.blank?
|
||||||
create_remote_site!
|
create_njalla_records! if remote_info['njalla'].blank?
|
||||||
save
|
save
|
||||||
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|
|
||||||
|
@ -115,7 +114,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? '.'
|
||||||
|
@ -123,7 +131,7 @@ 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 DistributedPress::V1::Error, HTTParty::Error => e
|
rescue HTTParty::Error => e
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||||
ensure
|
ensure
|
||||||
nil
|
nil
|
||||||
|
|
Loading…
Reference in a new issue