FIX: Killing a Unicorn worker shouldn't kill a running backup or restore process

By spawning and forking the backup and restore, the process owner changes from 🦄 to the init process.
This commit is contained in:
Gerhard Schlager
2020-10-13 17:40:21 +02:00
committed by Gerhard Schlager
parent 1febf11362
commit 57095f0bb7
2 changed files with 32 additions and 30 deletions

View File

@ -172,9 +172,9 @@ module BackupRestore
def self.spawn_process!(type, user_id, opts)
script = File.join(Rails.root, "script", "spawn_backup_restore.rb")
command = ["bundle", "exec", "ruby", script, type, user_id, opts.to_json].shelljoin
command = ["bundle", "exec", "ruby", script, type, user_id, opts.to_json].map(&:to_s)
pid = spawn({ "RAILS_DB" => RailsMultisite::ConnectionManagement.current_db }, command)
pid = spawn({ "RAILS_DB" => RailsMultisite::ConnectionManagement.current_db }, *command)
Process.detach(pid)
end