Skip to content

Commit b10d838

Browse files
committed
Change supervised to not be a mode
Modes will refer only to forked, async or inline. Stub fork mode for now.
1 parent b166bad commit b10d838

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

lib/solid_queue/processes/runnable.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def start
1313
run_callbacks(:boot) { boot }
1414
end
1515

16-
if mode.async?
16+
if running_async?
1717
@thread = Thread.new { run }
1818
else
1919
run
@@ -33,7 +33,7 @@ def mode
3333
end
3434

3535
def boot
36-
if supervised?
36+
if running_as_fork?
3737
register_signal_handlers
3838
set_procline
3939
end
@@ -65,5 +65,13 @@ def set_procline
6565
def running_inline?
6666
mode.inline?
6767
end
68+
69+
def running_async?
70+
mode.async?
71+
end
72+
73+
def running_as_fork?
74+
mode.fork?
75+
end
6876
end
6977
end

lib/solid_queue/processes/supervised.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module Supervised
99
end
1010

1111
def supervised_by(process)
12-
self.mode = :supervised
1312
@supervisor = process
1413
end
1514

@@ -19,11 +18,11 @@ def set_procline
1918
end
2019

2120
def supervisor_went_away?
22-
supervised? && supervisor&.pid != ::Process.ppid
21+
supervised? && supervisor.pid != ::Process.ppid
2322
end
2423

2524
def supervised?
26-
mode.supervised?
25+
supervisor.present?
2726
end
2827

2928
def register_signal_handlers

lib/solid_queue/supervisor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def release_orphaned_executions
127127

128128
def start_fork(configured_process)
129129
configured_process.supervised_by process
130+
configured_process.mode = :fork
130131

131132
pid = fork do
132133
configured_process.start

0 commit comments

Comments
 (0)