mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-14 17:58:16 +00:00
Merge branch 'issue-16462' into 'rails'
feat: poder agregar un nodo nuevo en segundo plano #16462 See merge request sutty/sutty!272
This commit is contained in:
commit
e576f5c805
4 changed files with 35 additions and 2 deletions
24
app/jobs/add_full_rsync_job.rb
Normal file
24
app/jobs/add_full_rsync_job.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Agrega un nodo nuevo en segundo plano y sincroniza todos los sitios
|
||||||
|
class AddFullRsyncJob < ApplicationJob
|
||||||
|
|
||||||
|
# Obtiene todos los sitios que estén sincronizando con un nodo de
|
||||||
|
# Sutty, agrega el nodo nuevo y empieza la sincronización.
|
||||||
|
#
|
||||||
|
# @param :hostname [String] El nombre del servidor remoto
|
||||||
|
# @param :destination [String] La ubicación de rsync
|
||||||
|
def perform(hostname:, destination:)
|
||||||
|
site_ids = DeployFullRsync.all.distinct.pluck(:site_id)
|
||||||
|
|
||||||
|
Site.where(id: site_ids).find_each do |site|
|
||||||
|
site
|
||||||
|
.deploys
|
||||||
|
.create(
|
||||||
|
type: 'DeployFullRsync',
|
||||||
|
destination: destination,
|
||||||
|
hostname: hostname
|
||||||
|
).deploy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@ require 'open3'
|
||||||
# :attributes`.
|
# :attributes`.
|
||||||
class Deploy < ApplicationRecord
|
class Deploy < ApplicationRecord
|
||||||
belongs_to :site
|
belongs_to :site
|
||||||
belongs_to :rol
|
belongs_to :rol, optional: true
|
||||||
|
|
||||||
has_many :build_stats, dependent: :destroy
|
has_many :build_stats, dependent: :destroy
|
||||||
|
|
||||||
|
|
8
db/migrate/20240614191548_deploy_rol_id_can_be_null.rb
Normal file
8
db/migrate/20240614191548_deploy_rol_id_can_be_null.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# El rol_id no es necesario para todos los deploys
|
||||||
|
class DeployRolIdCanBeNull < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
change_column :deploys, :rol_id, :integer, null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -2719,6 +2719,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20240316203721'),
|
('20240316203721'),
|
||||||
('20240318183846'),
|
('20240318183846'),
|
||||||
('20240319124212'),
|
('20240319124212'),
|
||||||
('20240319144735');
|
('20240319144735'),
|
||||||
|
('20240614191548');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue