bluepill 0.2.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +144 -1
- data/README.md +17 -10
- data/bin/bluepill +8 -2
- data/bluepill.gemspec +1 -1
- data/lib/bluepill/application/lifecycle.rb +43 -31
- data/lib/bluepill/application/listener.rb +1 -1
- data/lib/bluepill/application/previous_daemon.rb +14 -14
- data/lib/bluepill/application.rb +48 -28
- data/lib/bluepill/base_directory.rb +18 -20
- data/lib/bluepill/check_registry.rb +104 -0
- data/lib/bluepill/clock.rb +1 -3
- data/lib/bluepill/condition_watch.rb +61 -67
- data/lib/bluepill/controller/directory.rb +1 -3
- data/lib/bluepill/controller.rb +46 -38
- data/lib/bluepill/dsl/app_proxy.rb +69 -58
- data/lib/bluepill/dsl/attributes.rb +135 -0
- data/lib/bluepill/dsl/process_factory/child_factory.rb +80 -0
- data/lib/bluepill/dsl/process_factory/registry.rb +6 -26
- data/lib/bluepill/dsl/process_factory.rb +86 -70
- data/lib/bluepill/dsl/process_proxy.rb +61 -158
- data/lib/bluepill/dsl.rb +15 -6
- data/lib/bluepill/errors.rb +190 -0
- data/lib/bluepill/group.rb +14 -37
- data/lib/bluepill/logger.rb +55 -97
- data/lib/bluepill/process/attributes.rb +66 -32
- data/lib/bluepill/process/children.rb +4 -6
- data/lib/bluepill/process/pid.rb +41 -35
- data/lib/bluepill/process/state_machine.rb +15 -59
- data/lib/bluepill/process/stop_signals.rb +120 -0
- data/lib/bluepill/process/transition.rb +1 -3
- data/lib/bluepill/process/transition_callbacks.rb +2 -19
- data/lib/bluepill/process/triggers.rb +90 -0
- data/lib/bluepill/process/user_commands.rb +1 -1
- data/lib/bluepill/process/watches.rb +9 -23
- data/lib/bluepill/process.rb +70 -55
- data/lib/bluepill/process_commands/execution.rb +14 -22
- data/lib/bluepill/process_commands/hooks.rb +1 -31
- data/lib/bluepill/process_commands/stop_signals.rb +12 -17
- data/lib/bluepill/process_commands.rb +10 -8
- data/lib/bluepill/process_conditions/always_true.rb +2 -6
- data/lib/bluepill/process_conditions/below_threshold.rb +6 -8
- data/lib/bluepill/process_conditions/cpu_usage.rb +1 -4
- data/lib/bluepill/process_conditions/file_time.rb +8 -9
- data/lib/bluepill/process_conditions/http.rb +28 -43
- data/lib/bluepill/process_conditions/mem_usage.rb +7 -45
- data/lib/bluepill/process_conditions/process_condition.rb +30 -32
- data/lib/bluepill/process_conditions/zombie_process.rb +2 -6
- data/lib/bluepill/process_conditions.rb +5 -14
- data/lib/bluepill/process_journal/cleanup.rb +5 -53
- data/lib/bluepill/process_journal/config.rb +73 -0
- data/lib/bluepill/process_journal/entries.rb +128 -0
- data/lib/bluepill/process_journal/journal.rb +69 -0
- data/lib/bluepill/process_journal/kind.rb +60 -0
- data/lib/bluepill/process_journal/lock.rb +9 -4
- data/lib/bluepill/process_journal.rb +13 -324
- data/lib/bluepill/process_statistics.rb +3 -7
- data/lib/bluepill/socket.rb +19 -17
- data/lib/bluepill/system/command_options.rb +135 -0
- data/lib/bluepill/system/command_result.rb +73 -0
- data/lib/bluepill/system/command_setup.rb +3 -4
- data/lib/bluepill/system/commands.rb +21 -18
- data/lib/bluepill/system/daemon.rb +19 -14
- data/lib/bluepill/system/files.rb +35 -0
- data/lib/bluepill/system/ps.rb +20 -17
- data/lib/bluepill/system/ps_table.rb +7 -9
- data/lib/bluepill/system/usage.rb +155 -0
- data/lib/bluepill/system.rb +7 -192
- data/lib/bluepill/trigger.rb +22 -32
- data/lib/bluepill/triggers/flapping.rb +12 -8
- data/lib/bluepill/units.rb +7 -21
- data/lib/bluepill/util/log_error.rb +28 -0
- data/lib/bluepill/version.rb +12 -22
- data/lib/bluepill.rb +1 -0
- data/sig/bluepill/application.rbs +17 -12
- data/sig/bluepill/attributes.rbs +48 -0
- data/sig/bluepill/checks.rbs +43 -30
- data/sig/bluepill/dsl.rbs +98 -55
- data/sig/bluepill/errors.rbs +48 -0
- data/sig/bluepill/logger.rbs +15 -31
- data/sig/bluepill/process.rbs +42 -304
- data/sig/bluepill/process_commands.rbs +235 -0
- data/sig/bluepill/stop_signals.rbs +21 -0
- data/sig/bluepill/system.rbs +154 -99
- data/sig/bluepill/version.rbs +17 -0
- data/sig/bluepill.rbs +4 -17
- data/sig/manifest.yaml +1 -0
- metadata +22 -3
- data/lib/bluepill/dsl/process_factory/children.rb +0 -73
data/sig/bluepill/logger.rbs
CHANGED
|
@@ -21,15 +21,6 @@ module Bluepill
|
|
|
21
21
|
def debug: (String message) -> void
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
type options = {
|
|
25
|
-
?logger: Logger,
|
|
26
|
-
?prefix: String?,
|
|
27
|
-
?stdout: bool,
|
|
28
|
-
?log_file: String?,
|
|
29
|
-
?identity: String,
|
|
30
|
-
?log_level: (Symbol | String)?
|
|
31
|
-
}
|
|
32
|
-
|
|
33
24
|
LOG_METHODS: Array[Symbol]
|
|
34
25
|
|
|
35
26
|
# A ::Logger that also answers to the syslog method names
|
|
@@ -49,50 +40,43 @@ module Bluepill
|
|
|
49
40
|
alias notice info
|
|
50
41
|
end
|
|
51
42
|
|
|
52
|
-
@
|
|
53
|
-
@
|
|
54
|
-
@prefix: String?
|
|
55
|
-
@stdout: bool?
|
|
43
|
+
@log_file: String?
|
|
44
|
+
@identity: String
|
|
56
45
|
@level: Integer
|
|
46
|
+
@stdout: bool
|
|
57
47
|
@names: Array[String?]
|
|
58
48
|
@label: String?
|
|
49
|
+
# A one-element box that every logger made from the same one shares
|
|
59
50
|
@sink: Array[Object & _Backend]
|
|
60
51
|
@prefixes: Hash[String?, Logger]
|
|
61
52
|
|
|
62
|
-
def initialize: (?
|
|
53
|
+
def initialize: (?logger: (Object & _Backend)?, ?stdout: bool, ?log_file: String?, ?identity: String, ?log_level: Symbol | String) -> void
|
|
63
54
|
|
|
64
|
-
def emerg: (_ToS msg
|
|
55
|
+
def emerg: (_ToS msg) -> void
|
|
65
56
|
|
|
66
|
-
def alert: (_ToS msg
|
|
57
|
+
def alert: (_ToS msg) -> void
|
|
67
58
|
|
|
68
|
-
def crit: (_ToS msg
|
|
59
|
+
def crit: (_ToS msg) -> void
|
|
69
60
|
|
|
70
|
-
def err: (_ToS msg
|
|
61
|
+
def err: (_ToS msg) -> void
|
|
71
62
|
|
|
72
|
-
def warning: (_ToS msg
|
|
63
|
+
def warning: (_ToS msg) -> void
|
|
73
64
|
|
|
74
|
-
def notice: (_ToS msg
|
|
65
|
+
def notice: (_ToS msg) -> void
|
|
75
66
|
|
|
76
|
-
def info: (_ToS msg
|
|
67
|
+
def info: (_ToS msg) -> void
|
|
77
68
|
|
|
78
|
-
def debug: (_ToS msg
|
|
69
|
+
def debug: (_ToS msg) -> void
|
|
79
70
|
|
|
80
71
|
def prefix_with: (String? prefix) -> Logger
|
|
81
72
|
|
|
82
73
|
def reopen: () -> void
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
attr_reader stdout: bool?
|
|
87
|
-
|
|
88
|
-
attr_reader sink: Array[Object & _Backend]
|
|
89
|
-
|
|
90
|
-
attr_reader names: Array[String?]
|
|
75
|
+
# Protected in Ruby, and called on a copy, so public here
|
|
76
|
+
def add_prefix: (String? prefix) -> Logger
|
|
91
77
|
|
|
92
78
|
private
|
|
93
79
|
|
|
94
|
-
def settings_from: (Logger | (Object & _Backend) parent, Integer level) -> [Integer, Array[String?], bool?, Array[Object & _Backend]]
|
|
95
|
-
|
|
96
80
|
def label: (Array[String?] names) -> String?
|
|
97
81
|
|
|
98
82
|
def priority: (Symbol | String level) -> Integer
|
data/sig/bluepill/process.rbs
CHANGED
|
@@ -1,179 +1,10 @@
|
|
|
1
1
|
module Bluepill
|
|
2
|
-
# Runs commands for a Process, which is the only class that includes it
|
|
3
|
-
module ProcessCommands : _Host
|
|
4
|
-
# What ProcessCommands, and the modules it includes, use from Process
|
|
5
|
-
interface _Host
|
|
6
|
-
include Hooks::_Host
|
|
7
|
-
|
|
8
|
-
%a{pure} def children: () -> Array[Process]
|
|
9
|
-
%a{pure} def start_command: () -> String?
|
|
10
|
-
%a{pure} def stop_command: () -> String?
|
|
11
|
-
%a{pure} def restart_command: () -> String?
|
|
12
|
-
%a{pure} def stop_signals: () -> Array[Symbol | Integer]?
|
|
13
|
-
%a{pure} def start_grace_time: () -> seconds
|
|
14
|
-
%a{pure} def stop_grace_time: () -> seconds
|
|
15
|
-
%a{pure} def restart_grace_time: () -> seconds
|
|
16
|
-
%a{pure} def on_start_timeout: () -> (String | Symbol)
|
|
17
|
-
%a{pure} def monitor_children: () -> bool
|
|
18
|
-
%a{pure} def uid: () -> String?
|
|
19
|
-
%a{pure} def gid: () -> String?
|
|
20
|
-
%a{pure} def working_dir: () -> String?
|
|
21
|
-
%a{pure} def pid_file: () -> String?
|
|
22
|
-
%a{pure} def stdin: () -> String?
|
|
23
|
-
%a{pure} def stdout: () -> String?
|
|
24
|
-
%a{pure} def stderr: () -> String?
|
|
25
|
-
%a{pure} def supplementary_groups: () -> Array[String]?
|
|
26
|
-
def daemonize?: () -> bool
|
|
27
|
-
def monitor_children?: () -> bool
|
|
28
|
-
def clean_threads: () -> void
|
|
29
|
-
def signal_process: (Integer | String | Symbol code) -> bool
|
|
30
|
-
def unlink_pid: () -> void
|
|
31
|
-
def clear_pid: () -> void
|
|
32
|
-
def skip_ticks_for: (seconds seconds) -> Integer
|
|
33
|
-
def dispatch!: (Symbol | String event, ?String? reason) -> bool
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
include Execution
|
|
37
|
-
include Hooks
|
|
38
|
-
include StopSignals
|
|
39
|
-
|
|
40
|
-
@threads: Array[Thread]
|
|
41
|
-
@stopping_pid: Integer?
|
|
42
|
-
|
|
43
|
-
def start_process: () -> Integer
|
|
44
|
-
|
|
45
|
-
def run_start_command: (String command) -> void
|
|
46
|
-
|
|
47
|
-
def daemonize_process: (String command) -> void
|
|
48
|
-
|
|
49
|
-
def stop_process: () -> Integer
|
|
50
|
-
|
|
51
|
-
def journal_children: () -> void
|
|
52
|
-
|
|
53
|
-
def send_stop: () -> void
|
|
54
|
-
|
|
55
|
-
def run_stop_command: (String command) -> void
|
|
56
|
-
|
|
57
|
-
def restart_process: () -> Integer
|
|
58
|
-
|
|
59
|
-
def run_restart_command: (String command) -> Integer
|
|
60
|
-
|
|
61
|
-
def cleanup_process: () -> void
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Stops a Process with its stop_signals, with their delays
|
|
65
|
-
module ProcessCommands::StopSignals : ProcessCommands::StopSignals::_Host
|
|
66
|
-
# What StopSignals uses from Process
|
|
67
|
-
interface _Host
|
|
68
|
-
%a{pure} def logger: () -> Logger
|
|
69
|
-
%a{pure} def stop_grace_time: () -> seconds
|
|
70
|
-
def actual_pid: () -> Integer?
|
|
71
|
-
def signal_process: (Integer | String | Symbol code) -> bool
|
|
72
|
-
def cleanup_process: () -> void
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
@threads: Array[Thread]
|
|
76
|
-
|
|
77
|
-
def send_stop_signals_in_background: (Array[Symbol | Integer] signals) -> Array[Thread]
|
|
78
|
-
|
|
79
|
-
def send_stop_signals: (Array[Symbol | Integer] signals) -> void
|
|
80
|
-
|
|
81
|
-
def send_later_stop_signals: (Array[Symbol | Integer] signals) -> seconds?
|
|
82
|
-
|
|
83
|
-
def send_stop_signal: (Symbol | Integer signal) -> bool
|
|
84
|
-
|
|
85
|
-
def running_after?: (Integer delay) -> bool
|
|
86
|
-
|
|
87
|
-
def wait_for_stop: (seconds seconds) -> void
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Runs a Process's commands as its user, in its working_dir, with its
|
|
91
|
-
# environment and standard streams
|
|
92
|
-
module ProcessCommands::Execution : ProcessCommands::Execution::_Host
|
|
93
|
-
# What Execution uses from Process
|
|
94
|
-
interface _Host
|
|
95
|
-
%a{pure} def logger: () -> Logger
|
|
96
|
-
%a{pure} def uid: () -> String?
|
|
97
|
-
%a{pure} def gid: () -> String?
|
|
98
|
-
%a{pure} def working_dir: () -> String?
|
|
99
|
-
%a{pure} def environment: () -> Hash[_ToS, _ToS]?
|
|
100
|
-
%a{pure} def pid_file: () -> String?
|
|
101
|
-
%a{pure} def stdin: () -> String?
|
|
102
|
-
%a{pure} def stdout: () -> String?
|
|
103
|
-
%a{pure} def stderr: () -> String?
|
|
104
|
-
%a{pure} def supplementary_groups: () -> Array[String]?
|
|
105
|
-
def actual_pid: () -> Integer?
|
|
106
|
-
def dispatch!: (Symbol | String event, ?String? reason) -> bool
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def prepare_command: (String command) -> String
|
|
110
|
-
|
|
111
|
-
def substitute_pid: (String command, Integer? pid) -> String
|
|
112
|
-
|
|
113
|
-
def system_command_options: () -> System::command_options
|
|
114
|
-
|
|
115
|
-
# Runs the block, and dispatches next_state if it takes longer than secs
|
|
116
|
-
def with_timeout: [T] (seconds secs, String | Symbol next_state) { (Numeric secs) -> T } -> (T | bool)
|
|
117
|
-
|
|
118
|
-
def run_command: (String cmd, String description, ?System::command_options options) -> void
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# Runs the commands a Process has around its starts and stops, and on each
|
|
122
|
-
# change of state
|
|
123
|
-
module ProcessCommands::Hooks : ProcessCommands::Hooks::_Host
|
|
124
|
-
# What Hooks uses from Process
|
|
125
|
-
interface _Host
|
|
126
|
-
%a{pure} def name: () -> String
|
|
127
|
-
%a{pure} def logger: () -> Logger
|
|
128
|
-
%a{pure} def pre_start_command: () -> String?
|
|
129
|
-
%a{pure} def post_start_command: () -> String?
|
|
130
|
-
%a{pure} def pre_stop_command: () -> String?
|
|
131
|
-
%a{pure} def post_stop_command: () -> String?
|
|
132
|
-
%a{pure} def notify_command: () -> String?
|
|
133
|
-
%a{pure} def hook_timeout: () -> seconds
|
|
134
|
-
%a{pure} def app_name: () -> String?
|
|
135
|
-
%a{pure} def group_name: () -> String?
|
|
136
|
-
%a{pure} def environment: () -> Hash[_ToS, _ToS]?
|
|
137
|
-
def actual_pid: () -> Integer?
|
|
138
|
-
def system_command_options: () -> System::command_options
|
|
139
|
-
def substitute_pid: (String command, Integer? pid) -> String
|
|
140
|
-
def run_command: (String cmd, String description, ?System::command_options options) -> void
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
@stopping_pid: Integer?
|
|
144
|
-
@actual_pid: Integer?
|
|
145
|
-
@last_pid: Integer?
|
|
146
|
-
@transition_reason: String?
|
|
147
|
-
|
|
148
|
-
def pre_start_process: () -> void
|
|
149
|
-
|
|
150
|
-
def pre_stop_process: () -> void
|
|
151
|
-
|
|
152
|
-
def post_stop_process: () -> Thread?
|
|
153
|
-
|
|
154
|
-
def post_start_process: () -> Thread?
|
|
155
|
-
|
|
156
|
-
def notify_transition: (_Transition transition) -> Thread?
|
|
157
|
-
|
|
158
|
-
def notify_environment: (_Transition transition, Integer? pid) -> Hash[String, String]
|
|
159
|
-
|
|
160
|
-
def run_hook_in_background: (String command, String description, Integer? pid, ?Hash[String, String] env) -> Thread
|
|
161
|
-
|
|
162
|
-
def run_hook: (String command, String description, Integer? pid, ?Hash[String, String] env) -> void
|
|
163
|
-
|
|
164
|
-
def hook_options: (Hash[String, String] env) -> System::command_options
|
|
165
|
-
|
|
166
|
-
private
|
|
167
|
-
|
|
168
|
-
attr_reader stopping_pid: Integer?
|
|
169
|
-
|
|
170
|
-
attr_reader transition_reason: String?
|
|
171
|
-
|
|
172
|
-
def cached_pid: () -> Integer?
|
|
173
|
-
end
|
|
174
|
-
|
|
175
2
|
# A monitored process
|
|
176
3
|
class Process
|
|
4
|
+
# The checks a process is made with: each check's name and options, as
|
|
5
|
+
# a Hash or as a list of pairs, which can name a check twice
|
|
6
|
+
type checks = _Each[[Symbol, Hash[Symbol, untyped]]]
|
|
7
|
+
|
|
177
8
|
include ProcessCommands
|
|
178
9
|
include Attributes
|
|
179
10
|
include Pid
|
|
@@ -184,7 +15,7 @@ module Bluepill
|
|
|
184
15
|
|
|
185
16
|
attr_accessor name: String
|
|
186
17
|
attr_reader watches: Process::Watches
|
|
187
|
-
|
|
18
|
+
attr_reader triggers: Process::Triggers
|
|
188
19
|
attr_accessor skip_ticks_until: Integer?
|
|
189
20
|
attr_accessor process_running: bool?
|
|
190
21
|
|
|
@@ -213,18 +44,18 @@ module Bluepill
|
|
|
213
44
|
|
|
214
45
|
# Methods bluepill defines
|
|
215
46
|
|
|
216
|
-
def initialize: (String process_name,
|
|
47
|
+
def initialize: (String process_name, checks checks, ?logger: untyped, ?actual_pid: Integer?, **untyped attributes) -> void
|
|
217
48
|
|
|
218
49
|
# Runs the state machine's tick event, then the watches and children
|
|
219
50
|
def tick: () -> void
|
|
220
51
|
|
|
221
|
-
def
|
|
52
|
+
def tick_children: () -> void
|
|
222
53
|
|
|
223
|
-
def dispatch!: (Symbol
|
|
54
|
+
def dispatch!: (Symbol event, ?String? reason) -> bool
|
|
224
55
|
|
|
225
|
-
def add_checks: (
|
|
56
|
+
def add_checks: (checks checks, Logger logger) -> void
|
|
226
57
|
|
|
227
|
-
def
|
|
58
|
+
def add_check: (Symbol name, Hash[Symbol, untyped] options) -> void
|
|
228
59
|
|
|
229
60
|
# Runs the watches that are due, and dispatches their events
|
|
230
61
|
def run_watches: () -> void
|
|
@@ -238,109 +69,6 @@ module Bluepill
|
|
|
238
69
|
def skipping_ticks?: () -> bool?
|
|
239
70
|
end
|
|
240
71
|
|
|
241
|
-
# The options a config can set for a Process, and their defaults
|
|
242
|
-
module Process::Attributes
|
|
243
|
-
CONFIGURABLE_ATTRIBUTES: Array[Symbol]
|
|
244
|
-
|
|
245
|
-
attr_accessor pre_start_command: String?
|
|
246
|
-
attr_accessor start_command: String?
|
|
247
|
-
attr_accessor stop_command: String?
|
|
248
|
-
attr_accessor restart_command: String?
|
|
249
|
-
attr_accessor stdout: String?
|
|
250
|
-
attr_accessor stderr: String?
|
|
251
|
-
attr_accessor stdin: String?
|
|
252
|
-
attr_accessor daemonize: bool?
|
|
253
|
-
attr_accessor pid_file: String?
|
|
254
|
-
attr_accessor working_dir: String?
|
|
255
|
-
attr_accessor environment: Hash[_ToS, _ToS]?
|
|
256
|
-
attr_accessor start_grace_time: seconds
|
|
257
|
-
attr_accessor stop_grace_time: seconds
|
|
258
|
-
attr_accessor restart_grace_time: seconds
|
|
259
|
-
attr_accessor uid: String?
|
|
260
|
-
attr_accessor gid: String?
|
|
261
|
-
attr_accessor cache_actual_pid: bool
|
|
262
|
-
attr_accessor monitor_children: bool
|
|
263
|
-
attr_accessor child_process_factory: ProcessFactory?
|
|
264
|
-
attr_accessor pid_command: String?
|
|
265
|
-
attr_accessor auto_start: bool?
|
|
266
|
-
attr_accessor supplementary_groups: Array[String]?
|
|
267
|
-
# Signal names alternating with delays in seconds
|
|
268
|
-
attr_accessor stop_signals: Array[Symbol | Integer]?
|
|
269
|
-
attr_accessor on_start_timeout: String | Symbol
|
|
270
|
-
attr_accessor post_start_command: String?
|
|
271
|
-
attr_accessor pre_stop_command: String?
|
|
272
|
-
attr_accessor post_stop_command: String?
|
|
273
|
-
attr_accessor notify_command: String?
|
|
274
|
-
attr_accessor hook_timeout: seconds
|
|
275
|
-
attr_accessor group_start_noblock: bool
|
|
276
|
-
attr_accessor group_restart_noblock: bool
|
|
277
|
-
attr_accessor group_stop_noblock: bool
|
|
278
|
-
attr_accessor group_unmonitor_noblock: bool
|
|
279
|
-
|
|
280
|
-
def configure: (Hash[Symbol, untyped] options) -> void
|
|
281
|
-
|
|
282
|
-
def apply_defaults: () -> void
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
# Finds, signals and forgets a Process's pid
|
|
286
|
-
module Process::Pid : Process::Pid::_Host
|
|
287
|
-
# What Pid uses from Process
|
|
288
|
-
interface _Host
|
|
289
|
-
%a{pure} def name: () -> String
|
|
290
|
-
%a{pure} def logger: () -> Logger
|
|
291
|
-
%a{pure} def pid_file: () -> String?
|
|
292
|
-
%a{pure} def pid_command: () -> String?
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
@process_running: bool?
|
|
296
|
-
@cache_actual_pid: bool
|
|
297
|
-
@actual_pid: Integer?
|
|
298
|
-
@last_pid: Integer?
|
|
299
|
-
|
|
300
|
-
def process_running?: (?bool force) -> bool
|
|
301
|
-
|
|
302
|
-
def signal_process: (Integer | String | Symbol code) -> bool
|
|
303
|
-
|
|
304
|
-
def cache_actual_pid?: () -> bool
|
|
305
|
-
|
|
306
|
-
def actual_pid: () -> Integer?
|
|
307
|
-
|
|
308
|
-
def pid_from_file: () -> Integer?
|
|
309
|
-
|
|
310
|
-
def pid_from_command: () -> Integer?
|
|
311
|
-
|
|
312
|
-
def positive_pid: (Integer pid) -> Integer?
|
|
313
|
-
|
|
314
|
-
def actual_pid=: (Integer pid) -> void
|
|
315
|
-
|
|
316
|
-
def clear_pid: () -> nil
|
|
317
|
-
|
|
318
|
-
def unlink_pid: () -> void
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
# Keeps a Process for each of a Process's children, when it monitors them
|
|
322
|
-
module Process::Children : Process::Children::_Host
|
|
323
|
-
# What Children uses from Process
|
|
324
|
-
interface _Host
|
|
325
|
-
%a{pure} def name: () -> String
|
|
326
|
-
%a{pure} def logger: () -> Logger
|
|
327
|
-
%a{pure} def monitor_children: () -> bool
|
|
328
|
-
%a{pure} def child_process_factory: () -> ProcessFactory?
|
|
329
|
-
def daemonize?: () -> bool
|
|
330
|
-
def actual_pid: () -> Integer?
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
@children: Array[Process]
|
|
334
|
-
|
|
335
|
-
def monitor_children?: () -> bool
|
|
336
|
-
|
|
337
|
-
def refresh_children!: () -> void
|
|
338
|
-
|
|
339
|
-
def add_children: (Array[Integer] child_pids) -> void
|
|
340
|
-
|
|
341
|
-
def new_child: (ProcessFactory factory, Integer child_pid) -> Process
|
|
342
|
-
end
|
|
343
|
-
|
|
344
72
|
# Moves a Process between its states
|
|
345
73
|
module Process::StateMachine : Process::StateMachine::_Host
|
|
346
74
|
# What StateMachine uses from Process
|
|
@@ -373,14 +101,6 @@ module Bluepill
|
|
|
373
101
|
|
|
374
102
|
def restarting?: () -> bool
|
|
375
103
|
|
|
376
|
-
def start: () -> bool
|
|
377
|
-
|
|
378
|
-
def stop: () -> bool
|
|
379
|
-
|
|
380
|
-
def unmonitor: () -> bool
|
|
381
|
-
|
|
382
|
-
def restart: () -> bool
|
|
383
|
-
|
|
384
104
|
# Moves the process to the state an event leads to, and returns whether
|
|
385
105
|
# it moved
|
|
386
106
|
def fire_event: (Symbol event) -> bool
|
|
@@ -396,7 +116,7 @@ module Bluepill
|
|
|
396
116
|
interface _Host
|
|
397
117
|
%a{pure} def logger: () -> Logger
|
|
398
118
|
%a{pure} def watches: () -> Process::Watches
|
|
399
|
-
%a{pure} def triggers: () ->
|
|
119
|
+
%a{pure} def triggers: () -> Process::Triggers
|
|
400
120
|
%a{pure} def children: () -> Array[Process]
|
|
401
121
|
def monitor_children?: () -> bool
|
|
402
122
|
def clean_threads: () -> void
|
|
@@ -410,13 +130,12 @@ module Bluepill
|
|
|
410
130
|
STARTS: Array[Symbol]
|
|
411
131
|
|
|
412
132
|
@transitioned: bool
|
|
133
|
+
@triggers: Process::Triggers
|
|
413
134
|
|
|
414
135
|
def before_transition: (Process::Transition transition) -> true
|
|
415
136
|
|
|
416
137
|
def after_transition: (Process::Transition transition) -> void
|
|
417
138
|
|
|
418
|
-
def notify_triggers: (_Transition transition) -> void
|
|
419
|
-
|
|
420
139
|
def record_transition: (_Transition transition) -> void
|
|
421
140
|
end
|
|
422
141
|
|
|
@@ -431,16 +150,14 @@ module Bluepill
|
|
|
431
150
|
|
|
432
151
|
@watches: Array[ConditionWatch]
|
|
433
152
|
|
|
434
|
-
def initialize: () -> void
|
|
153
|
+
def initialize: (logger: Logger) -> void
|
|
435
154
|
|
|
436
|
-
def add: (Symbol name,
|
|
155
|
+
def add: (Symbol name, **untyped options) -> Process::Watches
|
|
437
156
|
|
|
438
157
|
def <<: (ConditionWatch watch) -> Process::Watches
|
|
439
158
|
|
|
440
159
|
def each: () { (ConditionWatch watch) -> void } -> Array[ConditionWatch]
|
|
441
160
|
|
|
442
|
-
def logger=: (Logger logger) -> void
|
|
443
|
-
|
|
444
161
|
def clear_history!: () -> void
|
|
445
162
|
|
|
446
163
|
# Yields for the process's pid on each due watch's thread
|
|
@@ -451,14 +168,35 @@ module Bluepill
|
|
|
451
168
|
def events: (Array[[ConditionWatch, Thread]] threads) -> Array[[Symbol, String]]
|
|
452
169
|
end
|
|
453
170
|
|
|
171
|
+
# The triggers a Process tells of its transitions
|
|
172
|
+
class Process::Triggers
|
|
173
|
+
include Enumerable[Trigger]
|
|
174
|
+
|
|
175
|
+
attr_reader logger: Logger
|
|
176
|
+
|
|
177
|
+
@triggers: Array[Trigger]
|
|
178
|
+
|
|
179
|
+
def initialize: (logger: Logger) -> void
|
|
180
|
+
|
|
181
|
+
def add: (Class klass, Process process, **untyped options) -> Process::Triggers
|
|
182
|
+
|
|
183
|
+
def <<: (Trigger trigger) -> Process::Triggers
|
|
184
|
+
|
|
185
|
+
def each: () { (Trigger trigger) -> void } -> Array[Trigger]
|
|
186
|
+
|
|
187
|
+
def notify: (_Transition transition) -> Array[Trigger]
|
|
188
|
+
|
|
189
|
+
def reset!: () -> Array[Trigger]
|
|
190
|
+
end
|
|
191
|
+
|
|
454
192
|
# Carries out the commands a user gives a Process from the command line
|
|
455
193
|
module Process::UserCommands : Process::UserCommands::_Host
|
|
456
194
|
# What UserCommands uses from Process
|
|
457
195
|
interface _Host
|
|
458
196
|
%a{pure} def logger: () -> Logger
|
|
459
|
-
%a{pure} def triggers: () ->
|
|
197
|
+
%a{pure} def triggers: () -> Process::Triggers
|
|
460
198
|
def process_running?: (?bool force) -> bool
|
|
461
|
-
def dispatch!: (Symbol
|
|
199
|
+
def dispatch!: (Symbol event, ?String? reason) -> bool
|
|
462
200
|
def stop_process: () -> Integer
|
|
463
201
|
def restart_process: () -> Integer
|
|
464
202
|
end
|
|
@@ -476,7 +214,7 @@ module Bluepill
|
|
|
476
214
|
|
|
477
215
|
# Keeps a short history of a process's events
|
|
478
216
|
class ProcessStatistics
|
|
479
|
-
type event = [Symbol
|
|
217
|
+
type event = [Symbol, String?, Time]
|
|
480
218
|
|
|
481
219
|
STRFTIME: String
|
|
482
220
|
EVENTS_TO_PERSIST: Integer
|
|
@@ -485,7 +223,7 @@ module Bluepill
|
|
|
485
223
|
|
|
486
224
|
def initialize: () -> void
|
|
487
225
|
|
|
488
|
-
def record_event: (Symbol
|
|
226
|
+
def record_event: (Symbol event, String? reason) -> Util::RotationalArray[event]
|
|
489
227
|
|
|
490
228
|
def to_s: () -> String
|
|
491
229
|
end
|
|
@@ -496,17 +234,17 @@ module Bluepill
|
|
|
496
234
|
attr_accessor name: String?
|
|
497
235
|
attr_accessor processes: Array[Process]
|
|
498
236
|
attr_accessor logger: Logger
|
|
499
|
-
# Not used by bluepill
|
|
500
|
-
attr_accessor process_logger: untyped
|
|
501
237
|
|
|
502
238
|
NOBLOCK: Hash[Symbol, Symbol]
|
|
503
239
|
|
|
504
|
-
def initialize: (String? name, ?
|
|
240
|
+
def initialize: (String? name, ?logger: untyped) -> void
|
|
505
241
|
|
|
506
242
|
def add_process: (Process process) -> Array[Process]
|
|
507
243
|
|
|
508
244
|
def tick: () -> void
|
|
509
245
|
|
|
246
|
+
def tick_children: () -> void
|
|
247
|
+
|
|
510
248
|
def determine_initial_state: () -> void
|
|
511
249
|
|
|
512
250
|
# Proxied events, which return the affected processes as group:process
|