Skip to content

Commit e0e1486

Browse files
committed
Create a new process for each background task
1 parent da2a56e commit e0e1486

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

script/background_daemon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Daemons.run_proc('background_daemon', dir_mode: :normal, dir: pid_dir, log_dir:
2121

2222
# Tasks may be longrunning so we want each one in a thread so one task won't
2323
# block other ones.
24-
threads = BackgroundTaskRegistry.all_tasks.map do |task|
25-
Thread.new do
24+
processes = BackgroundTaskRegistry.all_tasks.map do |task|
25+
Process.fork do
2626
loop do
2727
begin
2828
task.run
@@ -40,5 +40,5 @@ Daemons.run_proc('background_daemon', dir_mode: :normal, dir: pid_dir, log_dir:
4040
end
4141
end
4242
# TODO: we may not detect if only one of the threads dies.
43-
threads.each(&:join)
43+
processes.each(&:wait)
4444
end

0 commit comments

Comments
 (0)