mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 18:15:48 +08:00
BUGFIX: only wait for jobs of the current_site when backing up
This commit is contained in:
parent
99285f73e7
commit
ea953c9c0e
lib
@ -104,16 +104,25 @@ module Export
|
|||||||
|
|
||||||
def wait_for_sidekiq
|
def wait_for_sidekiq
|
||||||
log "Waiting for sidekiq to finish running jobs..."
|
log "Waiting for sidekiq to finish running jobs..."
|
||||||
iterations = 0
|
iterations = 1
|
||||||
workers = Sidekiq::Workers.new
|
while sidekiq_has_running_jobs?
|
||||||
while (running = workers.size) > 0
|
log "Waiting for sidekiq to finish running jobs... ##{iterations}"
|
||||||
log " Waiting for #{running} jobs..."
|
sleep 5
|
||||||
sleep 2
|
|
||||||
iterations += 1
|
iterations += 1
|
||||||
raise "Sidekiq did not finish running all the jobs in the allowed time!" if iterations >= 15
|
raise "Sidekiq did not finish running all the jobs in the allowed time!" if iterations > 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sidekiq_has_running_jobs?
|
||||||
|
Sidekiq::Workers.new.each do |process_id, thread_id, worker|
|
||||||
|
payload = worker.try(:payload)
|
||||||
|
return true if payload.try(:all_sites)
|
||||||
|
return true if payload.try(:current_site_id) == @current_db
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def write_metadata
|
def write_metadata
|
||||||
log "Writing metadata to '#{@meta_filename}'..."
|
log "Writing metadata to '#{@meta_filename}'..."
|
||||||
metadata = {
|
metadata = {
|
||||||
|
@ -123,16 +123,25 @@ module Import
|
|||||||
|
|
||||||
def wait_for_sidekiq
|
def wait_for_sidekiq
|
||||||
log "Waiting for sidekiq to finish running jobs..."
|
log "Waiting for sidekiq to finish running jobs..."
|
||||||
iterations = 0
|
iterations = 1
|
||||||
workers = Sidekiq::Workers.new
|
while sidekiq_has_running_jobs?
|
||||||
while (running = workers.size) > 0
|
log "Waiting for sidekiq to finish running jobs... ##{iterations}"
|
||||||
log " Waiting for #{running} jobs..."
|
|
||||||
sleep 5
|
sleep 5
|
||||||
iterations += 1
|
iterations += 1
|
||||||
raise "Sidekiq did not finish running all the jobs in the allowed time!" if iterations >= 20
|
raise "Sidekiq did not finish running all the jobs in the allowed time!" if iterations > 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sidekiq_has_running_jobs?
|
||||||
|
Sidekiq::Workers.new.each do |process_id, thread_id, worker|
|
||||||
|
payload = worker.try(:payload)
|
||||||
|
return true if payload.try(:all_sites)
|
||||||
|
return true if payload.try(:current_site_id) == @current_db
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def copy_archive_to_tmp_directory
|
def copy_archive_to_tmp_directory
|
||||||
log "Copying archive to tmp directory..."
|
log "Copying archive to tmp directory..."
|
||||||
source = File.join(Backup.base_directory, @filename)
|
source = File.join(Backup.base_directory, @filename)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user