Skip to content

Commit 9d6ad7b

Browse files
committed
Launch process prune from supervisor after forking supervised processes
Otherwise, the process prune thread seems to interfere with each forks' threads reloading, making them come to a halt when code is changed and they need to reload one at a time.
1 parent 023f610 commit 9d6ad7b

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/solid_queue/supervisor.rb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ module SolidQueue
44
class Supervisor < Processes::Base
55
include Processes::Signals
66

7-
after_boot :launch_process_prune
8-
97
class << self
108
def start(mode: :work, load_configuration_from: nil)
119
SolidQueue.supervisor = true
@@ -23,6 +21,8 @@ def initialize(*configured_processes)
2321
def start
2422
run_callbacks(:boot) { boot }
2523

24+
start_forks
25+
launch_process_prune
2626
supervise
2727
rescue Processes::GracefulTerminationRequested
2828
graceful_termination
@@ -42,8 +42,6 @@ def boot
4242
end
4343

4444
def supervise
45-
start_forks
46-
4745
loop do
4846
procline "supervising #{forks.keys.join(", ")}"
4947

@@ -63,15 +61,15 @@ def setup_pidfile
6361
end
6462
end
6563

66-
def launch_process_prune
67-
@prune_task = Concurrent::TimerTask.new(run_now: true, execution_interval: SolidQueue.process_alive_threshold) { prune_dead_processes }
68-
@prune_task.execute
69-
end
70-
7164
def start_forks
7265
configured_processes.each { |configured_process| start_fork(configured_process) }
7366
end
7467

68+
def launch_process_prune
69+
@prune_task = Concurrent::TimerTask.new(run_now: true, execution_interval: 2.seconds) { prune_dead_processes }
70+
@prune_task.execute
71+
end
72+
7573
def shutdown
7674
stop_process_prune
7775
restore_default_signal_handlers
@@ -116,9 +114,7 @@ def delete_pidfile
116114
end
117115

118116
def prune_dead_processes
119-
wrap_in_app_executor do
120-
SolidQueue::Process.prune
121-
end
117+
wrap_in_app_executor { SolidQueue::Process.prune }
122118
end
123119

124120
def start_fork(configured_process)

0 commit comments

Comments
 (0)