diff --git a/app/models/deploy_full_rsync.rb b/app/models/deploy_full_rsync.rb index b8c48eab..b417470a 100644 --- a/app/models/deploy_full_rsync.rb +++ b/app/models/deploy_full_rsync.rb @@ -27,8 +27,4 @@ class DeployFullRsync < DeployRsync result.present? && result.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 1dff2d99..fcc5a65d 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -38,6 +38,7 @@ class DeployRsync < Deploy # # @return [Boolean] def ssh? + return true if destination.start_with? 'rsync://' user, host = user_host ssh_available = false diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 5d28bf91..2c29538c 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -15,7 +15,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do add_role temporal: false, rol: 'usuarie' site.deploys.build type: 'DeployLocal' - sync_nodes + # Los sitios de testing no se sincronizan + sync_nodes unless site.name.end_with? '.testing' I18n.with_locale(usuarie.lang.to_sym || I18n.default_locale) do # No se puede llamar a site.config antes de save porque el sitio @@ -215,7 +216,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do # Crea los deploys necesarios para sincronizar a otros nodos de Sutty def sync_nodes Rails.application.nodes.each do |node| - site.deploys.build(type: 'DeployFullRsync', destination: "sutty@#{node}:") + site.deploys.build(type: 'DeployFullRsync', destination: "rsync://rsyncd.#{node}/deploys/", hostname: node) end end diff --git a/db/migrate/20230421182627_change_full_rsync_destination.rb b/db/migrate/20230421182627_change_full_rsync_destination.rb new file mode 100644 index 00000000..3a22aea6 --- /dev/null +++ b/db/migrate/20230421182627_change_full_rsync_destination.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# Envía los cambios a través de rsyncd +class ChangeFullRsyncDestination < ActiveRecord::Migration[6.1] + def up + DeployFullRsync.find_each do |deploy| + Rails.application.nodes.each do |node| + deploy.destination = "rsync://rsyncd.#{node}/deploys/" + deploy.save + end + end + end + + def down + DeployFullRsync.find_each do |deploy| + Rails.application.nodes.each do |node| + deploy.destination = "sutty@#{node}:" + deploy.save + end + end + end +end diff --git a/db/migrate/20230424174544_add_node_to_access_logs.rb b/db/migrate/20230424174544_add_node_to_access_logs.rb new file mode 100644 index 00000000..805fbc27 --- /dev/null +++ b/db/migrate/20230424174544_add_node_to_access_logs.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Agrega la columna de nodo a los logs +class AddNodeToAccessLogs < ActiveRecord::Migration[6.1] + def change + add_column :access_logs, :node, :string, index: true + end +end