File tree Expand file tree Collapse file tree 4 files changed +23
-24
lines changed Expand file tree Collapse file tree 4 files changed +23
-24
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,5 @@ module Callbacks
8
8
extend ActiveModel ::Callbacks
9
9
define_model_callbacks :boot , :shutdown
10
10
end
11
-
12
- private
13
- def boot
14
- end
15
-
16
- def shutdown
17
- end
18
11
end
19
12
end
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ def poll
39
39
raise NotImplementedError
40
40
end
41
41
42
+ def shutdown
43
+ end
44
+
42
45
def with_polling_volume
43
46
if SolidQueue . silence_polling? && ActiveRecord ::Base . logger
44
47
ActiveRecord ::Base . logger . silence { yield }
Original file line number Diff line number Diff line change @@ -18,18 +18,12 @@ def initialize(configuration)
18
18
end
19
19
20
20
def start
21
- run_callbacks ( : boot) { boot }
21
+ boot
22
22
23
23
start_processes
24
24
launch_maintenance_task
25
25
26
- loop do
27
- break if stopped?
28
-
29
- supervise
30
- end
31
- ensure
32
- run_callbacks ( :shutdown ) { shutdown }
26
+ supervise
33
27
end
34
28
35
29
def stop
@@ -40,8 +34,10 @@ def stop
40
34
attr_reader :configuration
41
35
42
36
def boot
43
- @stopped = false
44
- sync_std_streams
37
+ run_callbacks ( :boot ) do
38
+ @stopped = false
39
+ sync_std_streams
40
+ end
45
41
end
46
42
47
43
def start_processes
@@ -53,15 +49,16 @@ def stopped?
53
49
end
54
50
55
51
def supervise
56
- raise NotImplementedError
57
52
end
58
53
59
54
def start_process ( configured_process )
60
55
raise NotImplementedError
61
56
end
62
57
63
58
def shutdown
64
- stop_maintenance_task
59
+ run_callbacks ( :shutdown ) do
60
+ stop_maintenance_task
61
+ end
65
62
end
66
63
67
64
def sync_std_streams
Original file line number Diff line number Diff line change @@ -17,13 +17,19 @@ def kind
17
17
attr_reader :forks
18
18
19
19
def supervise
20
- procline "supervising #{ forks . keys . join ( ", " ) } "
21
- process_signal_queue
20
+ loop do
21
+ break if stopped?
22
+
23
+ procline "supervising #{ forks . keys . join ( ", " ) } "
24
+ process_signal_queue
22
25
23
- unless stopped?
24
- reap_and_replace_terminated_forks
25
- interruptible_sleep ( 1 . second )
26
+ unless stopped?
27
+ reap_and_replace_terminated_forks
28
+ interruptible_sleep ( 1 . second )
29
+ end
26
30
end
31
+ ensure
32
+ shutdown
27
33
end
28
34
29
35
def start_process ( configured_process )
You can’t perform that action at this time.
0 commit comments