solid_queue 0.3.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -6
- data/app/models/solid_queue/claimed_execution.rb +8 -3
- data/app/models/solid_queue/process/executor.rb +20 -0
- data/app/models/solid_queue/process/prunable.rb +15 -11
- data/app/models/solid_queue/process.rb +10 -9
- data/lib/puma/plugin/solid_queue.rb +33 -11
- data/lib/solid_queue/configuration.rb +18 -22
- data/lib/solid_queue/dispatcher/concurrency_maintenance.rb +1 -1
- data/lib/solid_queue/dispatcher.rb +3 -4
- data/lib/solid_queue/log_subscriber.rb +23 -20
- data/lib/solid_queue/processes/callbacks.rb +0 -7
- data/lib/solid_queue/processes/poller.rb +9 -10
- data/lib/solid_queue/processes/procline.rb +1 -1
- data/lib/solid_queue/processes/registrable.rb +9 -1
- data/lib/solid_queue/processes/runnable.rb +38 -7
- data/lib/solid_queue/processes/supervised.rb +2 -3
- data/lib/solid_queue/supervisor/async_supervisor.rb +44 -0
- data/lib/solid_queue/supervisor/fork_supervisor.rb +108 -0
- data/lib/solid_queue/supervisor/maintenance.rb +34 -0
- data/lib/solid_queue/{processes → supervisor}/pidfile.rb +2 -2
- data/lib/solid_queue/supervisor/pidfiled.rb +25 -0
- data/lib/solid_queue/supervisor/signals.rb +67 -0
- data/lib/solid_queue/supervisor.rb +30 -148
- data/lib/solid_queue/tasks.rb +1 -11
- data/lib/solid_queue/timer.rb +28 -0
- data/lib/solid_queue/version.rb +1 -1
- data/lib/solid_queue/worker.rb +4 -5
- metadata +14 -6
- data/lib/solid_queue/processes/signals.rb +0 -69
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidQueue::Processes
|
4
|
-
class GracefulTerminationRequested < Interrupt; end
|
5
|
-
class ImmediateTerminationRequested < Interrupt; end
|
6
|
-
|
7
|
-
module Signals
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
private
|
11
|
-
SIGNALS = %i[ QUIT INT TERM ]
|
12
|
-
|
13
|
-
def register_signal_handlers
|
14
|
-
SIGNALS.each do |signal|
|
15
|
-
trap(signal) do
|
16
|
-
signal_queue << signal
|
17
|
-
interrupt
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def restore_default_signal_handlers
|
23
|
-
SIGNALS.each do |signal|
|
24
|
-
trap(signal, :DEFAULT)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def process_signal_queue
|
29
|
-
while signal = signal_queue.shift
|
30
|
-
handle_signal(signal)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def handle_signal(signal)
|
35
|
-
case signal
|
36
|
-
when :TERM, :INT
|
37
|
-
request_graceful_termination
|
38
|
-
when :QUIT
|
39
|
-
request_immediate_termination
|
40
|
-
else
|
41
|
-
SolidQueue.instrument :unhandled_signal_error, signal: signal
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def request_graceful_termination
|
46
|
-
raise GracefulTerminationRequested
|
47
|
-
end
|
48
|
-
|
49
|
-
def request_immediate_termination
|
50
|
-
raise ImmediateTerminationRequested
|
51
|
-
end
|
52
|
-
|
53
|
-
def signal_processes(pids, signal)
|
54
|
-
pids.each do |pid|
|
55
|
-
signal_process pid, signal
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def signal_process(pid, signal)
|
60
|
-
::Process.kill signal, pid
|
61
|
-
rescue Errno::ESRCH
|
62
|
-
# Ignore, process died before
|
63
|
-
end
|
64
|
-
|
65
|
-
def signal_queue
|
66
|
-
@signal_queue ||= []
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|