Skip to content

Commit 9d81cc7

Browse files
committed
Guard against the case of maintenance tasks not having started before shutdown
And add an observer for the Supervisor's maintenance task and the heartbeat task as well.
1 parent ef21678 commit 9d81cc7

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

lib/solid_queue/dispatcher/concurrency_maintenance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def start
2525
end
2626

2727
def stop
28-
@concurrency_maintenance_task.shutdown
28+
@concurrency_maintenance_task&.shutdown
2929
end
3030

3131
private

lib/solid_queue/log_subscriber.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def shutdown_process(event)
7676
hostname: process.hostname
7777
}.merge(process.metadata)
7878

79-
info formatted_event(event, action: "Shut down #{process.kind}", **attributes)
79+
info formatted_event(event, action: "Shutdown #{process.kind}", **attributes)
8080
end
8181

8282
def register_process(event)

lib/solid_queue/processes/registrable.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def launch_heartbeat
3636
wrap_in_app_executor { heartbeat }
3737
end
3838

39+
@heartbeat_task.add_observer do |_, _, error|
40+
handle_thread_error(error) if error
41+
end
42+
3943
@heartbeat_task.execute
4044
end
4145

lib/solid_queue/supervisor/maintenance.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ module Supervisor::Maintenance
1010
def launch_maintenance_task
1111
@maintenance_task = Concurrent::TimerTask.new(run_now: true, execution_interval: SolidQueue.process_alive_threshold) do
1212
prune_dead_processes
13-
end.tap(&:execute)
13+
end
14+
15+
@maintenance_task.add_observer do |_, _, error|
16+
handle_thread_error(error) if error
17+
end
18+
19+
@maintenance_task.execute
1420
end
1521

1622
def stop_maintenance_task

0 commit comments

Comments
 (0)