mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-23 23:11:49 +00:00
Merge branch 'distributed-press' into panel.sutty.nl
This commit is contained in:
commit
2568a72eef
4 changed files with 43 additions and 9 deletions
2
Gemfile
2
Gemfile
|
@ -40,7 +40,7 @@ gem 'commonmarker'
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'devise-i18n'
|
gem 'devise-i18n'
|
||||||
gem 'devise_invitable'
|
gem 'devise_invitable'
|
||||||
gem 'distributed-press-api-client', '~> 0.2.1'
|
gem 'distributed-press-api-client', '~> 0.2.2'
|
||||||
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
|
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
|
||||||
gem 'exception_notification'
|
gem 'exception_notification'
|
||||||
gem 'fast_blank'
|
gem 'fast_blank'
|
||||||
|
|
|
@ -152,7 +152,7 @@ GEM
|
||||||
devise_invitable (2.0.6)
|
devise_invitable (2.0.6)
|
||||||
actionmailer (>= 5.0)
|
actionmailer (>= 5.0)
|
||||||
devise (>= 4.6)
|
devise (>= 4.6)
|
||||||
distributed-press-api-client (0.2.0)
|
distributed-press-api-client (0.2.2)
|
||||||
addressable (~> 2.3, >= 2.3.0)
|
addressable (~> 2.3, >= 2.3.0)
|
||||||
climate_control
|
climate_control
|
||||||
dry-schema
|
dry-schema
|
||||||
|
@ -581,7 +581,7 @@ DEPENDENCIES
|
||||||
devise
|
devise
|
||||||
devise-i18n
|
devise-i18n
|
||||||
devise_invitable
|
devise_invitable
|
||||||
distributed-press-api-client (~> 0.2.1)
|
distributed-press-api-client (~> 0.2.2)
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
down
|
down
|
||||||
ed25519
|
ed25519
|
||||||
|
|
|
@ -22,19 +22,32 @@ class DeployDistributedPress < Deploy
|
||||||
# @param :output [Bool]
|
# @param :output [Bool]
|
||||||
# @return [Bool]
|
# @return [Bool]
|
||||||
def deploy(output: true)
|
def deploy(output: true)
|
||||||
|
status = false
|
||||||
|
log = []
|
||||||
|
|
||||||
time_start
|
time_start
|
||||||
|
|
||||||
status = false
|
|
||||||
|
|
||||||
site_client.tap do |c|
|
site_client.tap do |c|
|
||||||
|
stdout = Thread.new(publisher.logger_out) do |io|
|
||||||
|
until io.eof?
|
||||||
|
line = io.gets
|
||||||
|
|
||||||
|
puts line if output
|
||||||
|
log << line
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
update remote_info: c.show(publishing_site).to_h
|
update remote_info: c.show(publishing_site).to_h
|
||||||
|
|
||||||
status = c.publish(publishing_site, deploy_local.destination)
|
status = c.publish(publishing_site, deploy_local.destination)
|
||||||
|
|
||||||
|
publisher.logger.close
|
||||||
|
stdout.join
|
||||||
end
|
end
|
||||||
|
|
||||||
time_stop
|
time_stop
|
||||||
|
|
||||||
create_stat! status
|
create_stat! status, log.join
|
||||||
|
|
||||||
status
|
status
|
||||||
end
|
end
|
||||||
|
@ -97,9 +110,10 @@ class DeployDistributedPress < Deploy
|
||||||
# Registra lo que sucedió
|
# Registra lo que sucedió
|
||||||
#
|
#
|
||||||
# @param status [Bool]
|
# @param status [Bool]
|
||||||
|
# @param log [String]
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def create_stat!(status)
|
def create_stat!(status, log)
|
||||||
build_stats.create action: publisher.to_s, seconds: time_spent_in_seconds, bytes: size, status: status
|
build_stats.create action: publisher.to_s,log: log, seconds: time_spent_in_seconds, bytes: size, status: status
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,11 @@ class DistributedPressPublisher < ApplicationRecord
|
||||||
# Cifrar la información del token en la base de datos
|
# Cifrar la información del token en la base de datos
|
||||||
has_encrypted :token
|
has_encrypted :token
|
||||||
|
|
||||||
|
# La salida del log
|
||||||
|
#
|
||||||
|
# @return [IO]
|
||||||
|
attr_reader :logger_out
|
||||||
|
|
||||||
# La instancia es única
|
# La instancia es única
|
||||||
validates_uniqueness_of :instance
|
validates_uniqueness_of :instance
|
||||||
|
|
||||||
|
@ -27,7 +32,7 @@ class DistributedPressPublisher < ApplicationRecord
|
||||||
#
|
#
|
||||||
# @return [DistributedPress::V1::Client]
|
# @return [DistributedPress::V1::Client]
|
||||||
def client
|
def client
|
||||||
@client ||= DistributedPress::V1::Client.new(url: instance, token: token)
|
@client ||= DistributedPress::V1::Client.new(url: instance, token: token, logger: logger)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [String]
|
# @return [String]
|
||||||
|
@ -35,8 +40,23 @@ class DistributedPressPublisher < ApplicationRecord
|
||||||
"Distributed Press <#{instance}>"
|
"Distributed Press <#{instance}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Logger]
|
||||||
|
def logger
|
||||||
|
@logger ||=
|
||||||
|
begin
|
||||||
|
@logger_out, @logger_in = IO.pipe
|
||||||
|
::Logger.new @logger_in, formatter: formatter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def formatter
|
||||||
|
@formatter ||= lambda do |_, _, _, msg|
|
||||||
|
"#{msg}\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Actualiza o desactiva la fecha de vencimiento a partir de la
|
# Actualiza o desactiva la fecha de vencimiento a partir de la
|
||||||
# información del token.
|
# información del token.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue