bluepill 0.2.5 → 0.2.9
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 +57 -1
- data/README.md +10 -8
- data/bluepill.gemspec +1 -1
- data/lib/bluepill/application/lifecycle.rb +3 -1
- data/lib/bluepill/application/previous_daemon.rb +6 -4
- data/lib/bluepill/application.rb +19 -3
- data/lib/bluepill/clock.rb +2 -4
- data/lib/bluepill/condition_watch.rb +26 -23
- data/lib/bluepill/controller.rb +22 -9
- data/lib/bluepill/deprecation/custom_checks.rb +193 -0
- data/lib/bluepill/deprecation/dsl.rb +141 -0
- data/lib/bluepill/deprecation/options.rb +140 -0
- data/lib/bluepill/deprecation.rb +92 -0
- data/lib/bluepill/dsl/app_proxy.rb +8 -1
- data/lib/bluepill/dsl/process_factory/children.rb +26 -0
- data/lib/bluepill/dsl/process_factory.rb +18 -1
- data/lib/bluepill/dsl/process_proxy.rb +23 -18
- data/lib/bluepill/dsl.rb +11 -3
- data/lib/bluepill/process/state_machine.rb +1 -1
- data/lib/bluepill/process/transition_callbacks.rb +4 -7
- data/lib/bluepill/process.rb +20 -8
- data/lib/bluepill/process_conditions/http.rb +28 -4
- data/lib/bluepill/process_conditions/process_condition.rb +17 -1
- data/lib/bluepill/trigger.rb +44 -3
- data/lib/bluepill/util/log_error.rb +28 -0
- data/lib/bluepill/version.rb +7 -7
- data/lib/bluepill.rb +1 -0
- data/sig/bluepill/application.rbs +7 -1
- data/sig/bluepill/checks.rbs +15 -2
- data/sig/bluepill/deprecation.rbs +87 -0
- data/sig/bluepill/dsl.rbs +8 -2
- data/sig/bluepill/process.rbs +4 -0
- data/sig/bluepill.rbs +3 -7
- metadata +8 -3
- data/lib/bluepill/util/levenshtein.rb +0 -55
data/lib/bluepill/process.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "bluepill/system"
|
|
4
|
+
require "bluepill/util/log_error"
|
|
4
5
|
require "bluepill/process_journal"
|
|
5
6
|
require "bluepill/process_commands"
|
|
6
7
|
require "bluepill/process/attributes"
|
|
@@ -138,28 +139,39 @@ module Bluepill
|
|
|
138
139
|
# Unless ticks are being skipped, fire the state machine's tick event, and
|
|
139
140
|
# then, for a process that's up, run its watches and tick its children.
|
|
140
141
|
#
|
|
142
|
+
# An error, such as one a trigger raised, is logged with its backtrace,
|
|
143
|
+
# and the process ticks again next time, so one broken check or trigger
|
|
144
|
+
# doesn't stop the daemon.
|
|
145
|
+
#
|
|
141
146
|
# @return [void]
|
|
142
147
|
#
|
|
143
148
|
# @api private
|
|
144
149
|
def tick
|
|
145
150
|
return if skipping_ticks?
|
|
146
151
|
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
@skip_ticks_until = nil
|
|
149
153
|
# clear the memoization per tick
|
|
150
154
|
@process_running = nil
|
|
151
|
-
|
|
152
155
|
# Deal with thread cleanup here since the stopping state isn't used
|
|
153
156
|
clean_threads if unmonitored?
|
|
154
|
-
|
|
155
157
|
fire_event(:tick)
|
|
156
|
-
|
|
157
158
|
return unless up?
|
|
158
159
|
|
|
159
160
|
run_watches
|
|
161
|
+
tick_children if monitor_children?
|
|
162
|
+
rescue => e
|
|
163
|
+
Util.log_error(logger, "tick failed", e)
|
|
164
|
+
end
|
|
160
165
|
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
# Find the process's children, and tick each of them
|
|
167
|
+
#
|
|
168
|
+
# Each child's tick logs its own errors, so one that fails doesn't keep
|
|
169
|
+
# the others from ticking.
|
|
170
|
+
#
|
|
171
|
+
# @return [void]
|
|
172
|
+
#
|
|
173
|
+
# @api private
|
|
174
|
+
def tick_children
|
|
163
175
|
refresh_children!
|
|
164
176
|
children.each(&:tick)
|
|
165
177
|
end
|
|
@@ -232,7 +244,7 @@ module Bluepill
|
|
|
232
244
|
#
|
|
233
245
|
# @api private
|
|
234
246
|
def add_trigger(name, options)
|
|
235
|
-
triggers << Trigger[name].
|
|
247
|
+
triggers << Trigger[name].create(self, name, **options, logger: logger)
|
|
236
248
|
end
|
|
237
249
|
|
|
238
250
|
# Run every watch that's due, and dispatch the events they fire
|
|
@@ -10,18 +10,25 @@ module Bluepill
|
|
|
10
10
|
# A config names it `checks :http`, with url: the URL to get, kind: the
|
|
11
11
|
# response it should be (a Net::HTTP class name such as :success or
|
|
12
12
|
# :ok, or a status code such as 200, :success by default), pattern: a
|
|
13
|
-
# Regexp its body should match,
|
|
14
|
-
# read_timeout:) in seconds, 5 by default
|
|
13
|
+
# Regexp its body should match, timeout: (or open_timeout: and
|
|
14
|
+
# read_timeout:) in seconds, 5 by default, and verify_ssl: true to
|
|
15
|
+
# verify an https server's certificate, which bluepill 0.3.0 does by
|
|
16
|
+
# default.
|
|
15
17
|
#
|
|
16
18
|
# @example
|
|
17
19
|
# process.checks :http, url: 'http://localhost:4567/', kind: :success, pattern: /html/, timeout: 3.seconds
|
|
20
|
+
# process.checks :http, url: 'https://example.com/', verify_ssl: true
|
|
18
21
|
#
|
|
19
22
|
# @api private
|
|
20
23
|
class Http < ProcessCondition
|
|
21
24
|
# Create the check
|
|
22
25
|
#
|
|
26
|
+
# It warns when an https check doesn't say whether to verify the
|
|
27
|
+
# server's certificate, since bluepill 0.3.0 verifies it by default.
|
|
28
|
+
#
|
|
23
29
|
# @param [Hash{Symbol => Object}] options the check's options, with
|
|
24
|
-
# :url, :kind, :pattern, :timeout, :open_timeout
|
|
30
|
+
# :url, :kind, :pattern, :timeout, :open_timeout, :read_timeout and
|
|
31
|
+
# :verify_ssl
|
|
25
32
|
#
|
|
26
33
|
# @return [void]
|
|
27
34
|
#
|
|
@@ -37,6 +44,8 @@ module Bluepill
|
|
|
37
44
|
@pattern = options[:pattern]
|
|
38
45
|
@open_timeout = (options[:open_timeout] || options[:timeout] || 5).to_i
|
|
39
46
|
@read_timeout = (options[:read_timeout] || options[:timeout] || 5).to_i
|
|
47
|
+
@verify_ssl = options.fetch(:verify_ssl, false)
|
|
48
|
+
warn_unverified(options)
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
# Get the URL
|
|
@@ -81,6 +90,21 @@ module Bluepill
|
|
|
81
90
|
|
|
82
91
|
private
|
|
83
92
|
|
|
93
|
+
# Warn about an https check that doesn't set verify_ssl
|
|
94
|
+
#
|
|
95
|
+
# @param [Hash{Symbol => Object}] options the check's options
|
|
96
|
+
#
|
|
97
|
+
# @return [void]
|
|
98
|
+
#
|
|
99
|
+
# @api private
|
|
100
|
+
def warn_unverified(options)
|
|
101
|
+
return unless @uri.scheme.eql?("https") && !options.key?(:verify_ssl)
|
|
102
|
+
|
|
103
|
+
Deprecation.warn("bluepill 0.3.0 verifies the certificate of an https check, so the check of #{@uri} fails " \
|
|
104
|
+
"if its certificate is self-signed or otherwise invalid. Add verify_ssl: true to verify it now, " \
|
|
105
|
+
"or verify_ssl: false to keep checking it without verification.")
|
|
106
|
+
end
|
|
107
|
+
|
|
84
108
|
# Return the Net::HTTPResponse class of a kind of response
|
|
85
109
|
#
|
|
86
110
|
# @param [Integer, String, Symbol, nil] kind a status code, such as
|
|
@@ -118,7 +142,7 @@ module Bluepill
|
|
|
118
142
|
if @uri.scheme.eql?("https")
|
|
119
143
|
require "net/https"
|
|
120
144
|
session.use_ssl = true
|
|
121
|
-
session.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
145
|
+
session.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
|
122
146
|
end
|
|
123
147
|
session.open_timeout = @open_timeout
|
|
124
148
|
session.read_timeout = @read_timeout
|
|
@@ -23,7 +23,23 @@ module Bluepill
|
|
|
23
23
|
# @return [Logger, nil] the process's logger
|
|
24
24
|
#
|
|
25
25
|
# @api public
|
|
26
|
-
|
|
26
|
+
attr_reader :logger
|
|
27
|
+
|
|
28
|
+
# Set the logger the condition writes to
|
|
29
|
+
#
|
|
30
|
+
# The watch sets it. Bluepill 0.3.0 removes it, so it warns when
|
|
31
|
+
# code outside bluepill calls it.
|
|
32
|
+
#
|
|
33
|
+
# @param [Logger, nil] logger the process's logger
|
|
34
|
+
#
|
|
35
|
+
# @return [void]
|
|
36
|
+
#
|
|
37
|
+
# @api private
|
|
38
|
+
def logger=(logger)
|
|
39
|
+
locations = caller_locations(0, 2) #: Array[Thread::Backtrace::Location]
|
|
40
|
+
Deprecation.check_logger_writer(self, locations.last)
|
|
41
|
+
@logger = logger
|
|
42
|
+
end
|
|
27
43
|
|
|
28
44
|
# Create a condition with the options a config gave its check
|
|
29
45
|
#
|
data/lib/bluepill/trigger.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "bluepill/util/log_error"
|
|
4
|
+
|
|
3
5
|
module Bluepill
|
|
4
6
|
# Reacts to a process's state transitions, as one of a process's checks
|
|
5
7
|
#
|
|
@@ -41,6 +43,29 @@ module Bluepill
|
|
|
41
43
|
@implementations[name]
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
# Create a trigger, and warn about what 0.3.0 rejects in its class
|
|
47
|
+
#
|
|
48
|
+
# The trigger gets its options as keyword arguments, which an
|
|
49
|
+
# initialize that takes an options Hash gets as the Hash, so a custom
|
|
50
|
+
# trigger can take them either way, as bluepill 0.3.0's need keywords.
|
|
51
|
+
#
|
|
52
|
+
# @param [Process] process the process the trigger watches
|
|
53
|
+
# @param [Symbol] check_name the name the config gave it, such as
|
|
54
|
+
# :flapping
|
|
55
|
+
# @param [Logger, nil] logger the process's logger
|
|
56
|
+
# @param [Hash{Symbol => Object}] options the trigger's options
|
|
57
|
+
#
|
|
58
|
+
# @return [Trigger] the trigger
|
|
59
|
+
#
|
|
60
|
+
# @api private
|
|
61
|
+
def self.create(process, check_name, logger:, **options)
|
|
62
|
+
Deprecation.check_options(check_name, options, Deprecation::NO_OPTIONS)
|
|
63
|
+
Deprecation.check_trigger_class(self)
|
|
64
|
+
trigger = new(process, **options, logger: logger) #: untyped
|
|
65
|
+
Deprecation.check_logger(trigger, logger)
|
|
66
|
+
trigger
|
|
67
|
+
end
|
|
68
|
+
|
|
44
69
|
# Return the process the trigger watches
|
|
45
70
|
#
|
|
46
71
|
# @return [Process] the process
|
|
@@ -53,7 +78,23 @@ module Bluepill
|
|
|
53
78
|
# @return [Logger] the process's logger
|
|
54
79
|
#
|
|
55
80
|
# @api private
|
|
56
|
-
|
|
81
|
+
attr_reader :logger
|
|
82
|
+
|
|
83
|
+
# Set the logger the trigger writes to
|
|
84
|
+
#
|
|
85
|
+
# The process sets it. Bluepill 0.3.0 removes it, so it warns when code
|
|
86
|
+
# outside bluepill calls it.
|
|
87
|
+
#
|
|
88
|
+
# @param [Logger, nil] logger the process's logger
|
|
89
|
+
#
|
|
90
|
+
# @return [void]
|
|
91
|
+
#
|
|
92
|
+
# @api private
|
|
93
|
+
def logger=(logger)
|
|
94
|
+
locations = caller_locations(0, 2) #: Array[Thread::Backtrace::Location]
|
|
95
|
+
Deprecation.check_logger_writer(self, locations.last)
|
|
96
|
+
@logger = logger
|
|
97
|
+
end
|
|
57
98
|
|
|
58
99
|
# Return the events the trigger scheduled, each with its thread
|
|
59
100
|
#
|
|
@@ -115,6 +156,7 @@ module Bluepill
|
|
|
115
156
|
#
|
|
116
157
|
# @api private
|
|
117
158
|
def dispatch!(event)
|
|
159
|
+
Deprecation.check_trigger_event(self, event)
|
|
118
160
|
process.dispatch!(event, @reason)
|
|
119
161
|
end
|
|
120
162
|
|
|
@@ -153,8 +195,7 @@ module Bluepill
|
|
|
153
195
|
scheduled_events.delete_if { |_, t| t.equal?(Thread.current) }
|
|
154
196
|
end
|
|
155
197
|
rescue => e
|
|
156
|
-
|
|
157
|
-
logger.err(e.backtrace.to_a.join("\n"))
|
|
198
|
+
Util.log_error(logger, "#{@reason} failed to dispatch #{event}", e)
|
|
158
199
|
end
|
|
159
200
|
|
|
160
201
|
# Cancel every scheduled event, killing its thread
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bluepill
|
|
4
|
+
module Util
|
|
5
|
+
# Log an error at err, with a line of its own for each backtrace line
|
|
6
|
+
#
|
|
7
|
+
# The daemon rescues what a check, a trigger or a tick raises, so the
|
|
8
|
+
# log is the only place the error shows.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# Bluepill::Util.log_error(logger, "mem_usage check failed", error)
|
|
12
|
+
# # mem_usage check failed: RuntimeError: boom
|
|
13
|
+
# # /path/to/check.rb:12:in `run'
|
|
14
|
+
#
|
|
15
|
+
# @param [Logger] logger the logger to write to
|
|
16
|
+
# @param [String] summary what failed, which the error's class and
|
|
17
|
+
# message follow
|
|
18
|
+
# @param [Exception] error the error
|
|
19
|
+
#
|
|
20
|
+
# @return [void]
|
|
21
|
+
#
|
|
22
|
+
# @api private
|
|
23
|
+
def self.log_error(logger, summary, error)
|
|
24
|
+
logger.err("#{summary}: #{error.class}: #{error}")
|
|
25
|
+
error.backtrace&.each { |line| logger.err(line) }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/bluepill/version.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Bluepill
|
|
|
4
4
|
# The version of bluepill
|
|
5
5
|
#
|
|
6
6
|
# @example
|
|
7
|
-
# Bluepill::Version.to_s # => "0.2.
|
|
7
|
+
# Bluepill::Version.to_s # => "0.2.9"
|
|
8
8
|
#
|
|
9
9
|
# @api public
|
|
10
10
|
module Version
|
|
@@ -35,13 +35,13 @@ module Bluepill
|
|
|
35
35
|
# Return the patch version
|
|
36
36
|
#
|
|
37
37
|
# @example
|
|
38
|
-
# Bluepill::Version.patch # =>
|
|
38
|
+
# Bluepill::Version.patch # => 9
|
|
39
39
|
#
|
|
40
40
|
# @return [Integer] the patch version
|
|
41
41
|
#
|
|
42
42
|
# @api public
|
|
43
43
|
def self.patch
|
|
44
|
-
|
|
44
|
+
9
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Return the pre-release version
|
|
@@ -58,7 +58,7 @@ module Bluepill
|
|
|
58
58
|
# Return the version's parts by name
|
|
59
59
|
#
|
|
60
60
|
# @example
|
|
61
|
-
# Bluepill::Version.to_h # => {major: 0, minor: 2, patch:
|
|
61
|
+
# Bluepill::Version.to_h # => {major: 0, minor: 2, patch: 9, pre: nil}
|
|
62
62
|
#
|
|
63
63
|
# @return [Hash{Symbol => Integer, nil}] the major, minor, patch and
|
|
64
64
|
# pre-release versions
|
|
@@ -76,7 +76,7 @@ module Bluepill
|
|
|
76
76
|
# Return the version's parts, without a missing pre-release version
|
|
77
77
|
#
|
|
78
78
|
# @example
|
|
79
|
-
# Bluepill::Version.to_a # => [0, 2,
|
|
79
|
+
# Bluepill::Version.to_a # => [0, 2, 9]
|
|
80
80
|
#
|
|
81
81
|
# @return [Array<Integer>] the parts of the version
|
|
82
82
|
#
|
|
@@ -88,9 +88,9 @@ module Bluepill
|
|
|
88
88
|
# Return the version as a string
|
|
89
89
|
#
|
|
90
90
|
# @example
|
|
91
|
-
# Bluepill::Version.to_s # => "0.2.
|
|
91
|
+
# Bluepill::Version.to_s # => "0.2.9"
|
|
92
92
|
#
|
|
93
|
-
# @return [String] the version, such as "0.2.
|
|
93
|
+
# @return [String] the version, such as "0.2.9"
|
|
94
94
|
#
|
|
95
95
|
# @api public
|
|
96
96
|
def self.to_s
|
data/lib/bluepill.rb
CHANGED
|
@@ -45,12 +45,15 @@ module Bluepill
|
|
|
45
45
|
|
|
46
46
|
def add_process: (Process process, ?_ToS? group_name) -> Array[Process]
|
|
47
47
|
|
|
48
|
-
def version: () ->
|
|
48
|
+
def version: () -> String
|
|
49
49
|
|
|
50
50
|
# Ruby's protected methods are private in RBS
|
|
51
51
|
|
|
52
52
|
private
|
|
53
53
|
|
|
54
|
+
# Logs an error that stopped the daemon at crit, with its backtrace
|
|
55
|
+
def log_crash: (StandardError error) -> void
|
|
56
|
+
|
|
54
57
|
def send_to_process_or_group: (Symbol method, String? group_name, String? process_name) -> Array[String]
|
|
55
58
|
|
|
56
59
|
def send_to_groups: (Symbol method, *String args) -> Array[String]
|
|
@@ -162,6 +165,9 @@ module Bluepill
|
|
|
162
165
|
class Controller
|
|
163
166
|
include Directory
|
|
164
167
|
|
|
168
|
+
TAIL_COMMAND: String
|
|
169
|
+
OUT_OF_DATE: String
|
|
170
|
+
|
|
165
171
|
attr_accessor base_dir: String
|
|
166
172
|
attr_accessor log_file: String?
|
|
167
173
|
attr_reader base_directory: BaseDirectory
|
data/sig/bluepill/checks.rbs
CHANGED
|
@@ -58,8 +58,14 @@ module Bluepill
|
|
|
58
58
|
|
|
59
59
|
def self.[]: %a{implicitly-returns-nil} (Symbol name) -> singleton(Trigger)
|
|
60
60
|
|
|
61
|
+
# Makes a trigger, and warns about what 0.3.0 rejects in its class
|
|
62
|
+
def self.create: (Process process, Symbol check_name, logger: Logger?, **untyped options) -> Trigger
|
|
63
|
+
|
|
61
64
|
attr_accessor process: Process
|
|
62
|
-
|
|
65
|
+
attr_reader logger: Logger
|
|
66
|
+
|
|
67
|
+
# Sets the logger, and warns when code outside bluepill calls it
|
|
68
|
+
def logger=: (Logger logger) -> void
|
|
63
69
|
attr_reader scheduled_events: Array[[Symbol, Thread]]
|
|
64
70
|
|
|
65
71
|
@reason: String
|
|
@@ -113,7 +119,10 @@ module Bluepill
|
|
|
113
119
|
@options: Hash[Symbol, untyped]
|
|
114
120
|
|
|
115
121
|
# The watch's logger
|
|
116
|
-
|
|
122
|
+
attr_reader logger: Logger?
|
|
123
|
+
|
|
124
|
+
# Sets the logger, and warns when code outside bluepill calls it
|
|
125
|
+
def logger=: (Logger? logger) -> void
|
|
117
126
|
|
|
118
127
|
def initialize: (?Hash[Symbol, untyped] options) -> void
|
|
119
128
|
|
|
@@ -160,6 +169,7 @@ module Bluepill
|
|
|
160
169
|
@pattern: Regexp?
|
|
161
170
|
@open_timeout: Integer
|
|
162
171
|
@read_timeout: Integer
|
|
172
|
+
@verify_ssl: boolish
|
|
163
173
|
|
|
164
174
|
def run: (Integer? pid, boolish include_children) -> (Net::HTTPResponse | StandardError)
|
|
165
175
|
|
|
@@ -167,6 +177,9 @@ module Bluepill
|
|
|
167
177
|
|
|
168
178
|
private
|
|
169
179
|
|
|
180
|
+
# Warns about an https check that doesn't set verify_ssl
|
|
181
|
+
def warn_unverified: (Hash[Symbol, untyped] options) -> void
|
|
182
|
+
|
|
170
183
|
def response_class: (untyped kind) -> Class
|
|
171
184
|
|
|
172
185
|
def new_session: () -> Net::HTTP
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module Bluepill
|
|
2
|
+
# Warns, once each, about what bluepill 0.3.0 changes
|
|
3
|
+
module Deprecation
|
|
4
|
+
RUBY_REQUIRED: Integer
|
|
5
|
+
|
|
6
|
+
self.@warned: Set[String]
|
|
7
|
+
self.@logger: Logger?
|
|
8
|
+
|
|
9
|
+
# Warns about a change, unless the same warning was given
|
|
10
|
+
def self.warn: (String message) -> void
|
|
11
|
+
|
|
12
|
+
def self.logger: () -> Logger?
|
|
13
|
+
|
|
14
|
+
def self.logger=: (Logger? logger) -> void
|
|
15
|
+
|
|
16
|
+
# Forgets the warnings given and the logger
|
|
17
|
+
def self.reset!: () -> void
|
|
18
|
+
|
|
19
|
+
# Warns when bluepill runs on a Ruby that 0.3.0 doesn't support
|
|
20
|
+
def self.check_ruby: (?String version) -> void
|
|
21
|
+
|
|
22
|
+
LIB_DIR: String
|
|
23
|
+
POSITIONAL: Array[Symbol]
|
|
24
|
+
|
|
25
|
+
# Warns about what a custom check's class does that 0.3.0 rejects
|
|
26
|
+
def self.check_condition_class: (Class klass) -> void
|
|
27
|
+
|
|
28
|
+
# Warns about what a custom trigger's class does that 0.3.0 rejects
|
|
29
|
+
def self.check_trigger_class: (Class klass) -> void
|
|
30
|
+
|
|
31
|
+
def self.check_logger: (ProcessConditions::ProcessCondition[untyped] | Trigger check, Logger? logger) -> void
|
|
32
|
+
|
|
33
|
+
def self.check_logger_writer: (ProcessConditions::ProcessCondition[untyped] | Trigger check, Thread::Backtrace::Location? location) -> void
|
|
34
|
+
|
|
35
|
+
def self.check_trigger_event: (Trigger trigger, untyped event) -> void
|
|
36
|
+
|
|
37
|
+
def self.warn_positional_options: (Class klass, String kind, Integer positional) -> void
|
|
38
|
+
|
|
39
|
+
def self.warn_check_methods: (Class klass, Class base) -> void
|
|
40
|
+
|
|
41
|
+
def self.warn_missing_methods: (Class klass, Class base, bool checks) -> void
|
|
42
|
+
|
|
43
|
+
def self.custom?: (UnboundMethod method) -> bool
|
|
44
|
+
|
|
45
|
+
def self.positional_options?: (UnboundMethod initialize, Integer positional) -> bool
|
|
46
|
+
|
|
47
|
+
CHILD_ATTRIBUTES: Array[Symbol]
|
|
48
|
+
|
|
49
|
+
# Warns about a way of setting a process attribute that 0.3.0 removes
|
|
50
|
+
def self.check_attribute: (Symbol name, Symbol key) -> void
|
|
51
|
+
|
|
52
|
+
def self.check_monitor_children: (String process_name, Proc? block) -> void
|
|
53
|
+
|
|
54
|
+
def self.check_child_stop_command: (String parent_name, Hash[Symbol, untyped] attributes) -> void
|
|
55
|
+
|
|
56
|
+
def self.check_daemon_version: (Module | String version) -> void
|
|
57
|
+
|
|
58
|
+
APPLICATION_OPTIONS: Array[Symbol]
|
|
59
|
+
|
|
60
|
+
# Warns about options passed as a Hash, without **
|
|
61
|
+
def self.check_keywords: (Hash[Symbol, untyped]? options, Hash[Symbol, untyped] keywords, String call) -> void
|
|
62
|
+
|
|
63
|
+
def self.check_application_options: (Hash[Symbol, untyped] options) -> void
|
|
64
|
+
|
|
65
|
+
def self.check_duplicate_check: (Symbol name) -> void
|
|
66
|
+
|
|
67
|
+
EVENTS: Array[Symbol]
|
|
68
|
+
EVENTS_LIST: String
|
|
69
|
+
NO_OPTIONS: Array[Symbol]
|
|
70
|
+
CHECK_OPTIONS: Hash[Symbol, Array[Symbol]]
|
|
71
|
+
REQUIRED_OPTIONS: Hash[Symbol, Array[Symbol]]
|
|
72
|
+
|
|
73
|
+
# Warns about the options of a check that 0.3.0 rejects or needs
|
|
74
|
+
def self.check_options: (Symbol | String name, Hash[untyped, untyped] options, Array[Symbol] taken) -> void
|
|
75
|
+
|
|
76
|
+
def self.warn_unknown_options: (Symbol check, Array[untyped] unknown) -> void
|
|
77
|
+
|
|
78
|
+
def self.warn_missing_options: (Symbol check, Array[Symbol] missing) -> void
|
|
79
|
+
|
|
80
|
+
# Warns about a watch's options and events that 0.3.0 rejects
|
|
81
|
+
def self.check_watch: (Symbol | String name, Hash[Symbol, untyped] options, Array[untyped] events) -> void
|
|
82
|
+
|
|
83
|
+
def self.check_fires: (Symbol | String name, Array[untyped] events) -> void
|
|
84
|
+
|
|
85
|
+
def self.check_on_start_timeout: (String process_name, Hash[Symbol, untyped] attributes) -> void
|
|
86
|
+
end
|
|
87
|
+
end
|
data/sig/bluepill/dsl.rbs
CHANGED
|
@@ -2,6 +2,7 @@ module Bluepill
|
|
|
2
2
|
# self in an application block
|
|
3
3
|
class AppProxy
|
|
4
4
|
APP_ATTRIBUTES: Array[Symbol]
|
|
5
|
+
NO_OPTIONS: Hash[Symbol, untyped]
|
|
5
6
|
|
|
6
7
|
attr_accessor working_dir: String?
|
|
7
8
|
attr_accessor uid: String?
|
|
@@ -14,7 +15,7 @@ module Bluepill
|
|
|
14
15
|
|
|
15
16
|
@registry: ProcessFactory::Registry
|
|
16
17
|
|
|
17
|
-
def initialize: (_ToS app_name, Hash[Symbol, untyped] options) -> void
|
|
18
|
+
def initialize: (_ToS app_name, ?Hash[Symbol, untyped] options) -> void
|
|
18
19
|
|
|
19
20
|
# The block runs with self set to the ProcessProxy, and also gets it as
|
|
20
21
|
# an argument
|
|
@@ -37,6 +38,8 @@ module Bluepill
|
|
|
37
38
|
|
|
38
39
|
private
|
|
39
40
|
|
|
41
|
+
def child_factory: (String name, Hash[Symbol, untyped] attributes, process_block child_process_block) -> ProcessFactory
|
|
42
|
+
|
|
40
43
|
def assign_default_pid_file: (Hash[Symbol, untyped] attributes, String process_name, String pids_dir) -> String?
|
|
41
44
|
|
|
42
45
|
def validate_process!: (ProcessProxy process) -> void
|
|
@@ -81,6 +84,9 @@ module Bluepill
|
|
|
81
84
|
|
|
82
85
|
def create_child_process: (String name, Integer pid, Logger logger) -> Process
|
|
83
86
|
|
|
87
|
+
# Warns about what 0.3.0 rejects in the children's block
|
|
88
|
+
def check_children: (String parent_name) -> void
|
|
89
|
+
|
|
84
90
|
private
|
|
85
91
|
|
|
86
92
|
def inherited_attributes: () -> Hash[Symbol, untyped]
|
|
@@ -108,7 +114,7 @@ module Bluepill
|
|
|
108
114
|
|
|
109
115
|
def self.attribute_names: () -> Array[Symbol]
|
|
110
116
|
|
|
111
|
-
def checks: (Symbol name, ?Hash[Symbol, untyped] options) -> Hash[Symbol, untyped]
|
|
117
|
+
def checks: (Symbol name, ?Hash[Symbol, untyped]? options, **untyped keywords) -> Hash[Symbol, untyped]
|
|
112
118
|
|
|
113
119
|
# The block configures the children like a process block
|
|
114
120
|
def monitor_children: () ?{ (ProcessProxy child) [self: ProcessProxy] -> void } -> process_block?
|
data/sig/bluepill/process.rbs
CHANGED
|
@@ -218,6 +218,8 @@ module Bluepill
|
|
|
218
218
|
# Runs the state machine's tick event, then the watches and children
|
|
219
219
|
def tick: () -> void
|
|
220
220
|
|
|
221
|
+
def tick_children: () -> void
|
|
222
|
+
|
|
221
223
|
def logger=: (Logger logger) -> void
|
|
222
224
|
|
|
223
225
|
def dispatch!: (Symbol | String event, ?String? reason) -> bool
|
|
@@ -507,6 +509,8 @@ module Bluepill
|
|
|
507
509
|
|
|
508
510
|
def tick: () -> void
|
|
509
511
|
|
|
512
|
+
def tick_children: () -> void
|
|
513
|
+
|
|
510
514
|
def determine_initial_state: () -> void
|
|
511
515
|
|
|
512
516
|
# Proxied events, which return the affected processes as group:process
|
data/sig/bluepill.rbs
CHANGED
|
@@ -15,7 +15,7 @@ module Bluepill
|
|
|
15
15
|
|
|
16
16
|
# Loads an application from a config file. The block runs with self set to
|
|
17
17
|
# the AppProxy, and also gets it as an argument.
|
|
18
|
-
def self.application: (_ToS app_name, ?Hash[Symbol, untyped] options) { (AppProxy app) [self: AppProxy] -> void } -> void
|
|
18
|
+
def self.application: (_ToS app_name, ?Hash[Symbol, untyped]? options, **untyped keywords) { (AppProxy app) [self: AppProxy] -> void } -> void
|
|
19
19
|
|
|
20
20
|
module Version
|
|
21
21
|
def self.major: () -> Integer
|
|
@@ -93,12 +93,8 @@ module Bluepill
|
|
|
93
93
|
# does
|
|
94
94
|
def self.underscore: (String name) -> String
|
|
95
95
|
|
|
96
|
-
#
|
|
97
|
-
def self.
|
|
98
|
-
|
|
99
|
-
private
|
|
100
|
-
|
|
101
|
-
def self.next_levenshtein_row!: (Array[Integer] row, Integer from_length, String from_char, String to) -> void
|
|
96
|
+
# Logs an error at err, with a line for each backtrace line
|
|
97
|
+
def self.log_error: (Logger logger, String summary, Exception error) -> void
|
|
102
98
|
|
|
103
99
|
# An array that drops its oldest element when it grows past its capacity
|
|
104
100
|
class RotationalArray[Elem] < Array[Elem]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bluepill
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arya Asemanfar
|
|
@@ -43,6 +43,10 @@ files:
|
|
|
43
43
|
- lib/bluepill/controller.rb
|
|
44
44
|
- lib/bluepill/controller/directory.rb
|
|
45
45
|
- lib/bluepill/daemonize.rb
|
|
46
|
+
- lib/bluepill/deprecation.rb
|
|
47
|
+
- lib/bluepill/deprecation/custom_checks.rb
|
|
48
|
+
- lib/bluepill/deprecation/dsl.rb
|
|
49
|
+
- lib/bluepill/deprecation/options.rb
|
|
46
50
|
- lib/bluepill/dsl.rb
|
|
47
51
|
- lib/bluepill/dsl/app_proxy.rb
|
|
48
52
|
- lib/bluepill/dsl/process_factory.rb
|
|
@@ -90,12 +94,13 @@ files:
|
|
|
90
94
|
- lib/bluepill/triggers/flapping.rb
|
|
91
95
|
- lib/bluepill/units.rb
|
|
92
96
|
- lib/bluepill/util/inflections.rb
|
|
93
|
-
- lib/bluepill/util/
|
|
97
|
+
- lib/bluepill/util/log_error.rb
|
|
94
98
|
- lib/bluepill/util/rotational_array.rb
|
|
95
99
|
- lib/bluepill/version.rb
|
|
96
100
|
- sig/bluepill.rbs
|
|
97
101
|
- sig/bluepill/application.rbs
|
|
98
102
|
- sig/bluepill/checks.rbs
|
|
103
|
+
- sig/bluepill/deprecation.rbs
|
|
99
104
|
- sig/bluepill/dsl.rbs
|
|
100
105
|
- sig/bluepill/logger.rbs
|
|
101
106
|
- sig/bluepill/process.rbs
|
|
@@ -116,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
116
121
|
requirements:
|
|
117
122
|
- - ">="
|
|
118
123
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: '2.
|
|
124
|
+
version: '2.7'
|
|
120
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
126
|
requirements:
|
|
122
127
|
- - ">="
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bluepill
|
|
4
|
-
module Util
|
|
5
|
-
# Return how many edits turn one string into another
|
|
6
|
-
#
|
|
7
|
-
# Counts the characters to insert, delete or replace (the Levenshtein
|
|
8
|
-
# distance), a row of the table at a time. ProcessProxy uses it to
|
|
9
|
-
# suggest the attribute closest to a misspelled one.
|
|
10
|
-
#
|
|
11
|
-
# @example
|
|
12
|
-
# Bluepill::Util.levenshtein_distance("start_comand", "start_command") # => 1
|
|
13
|
-
#
|
|
14
|
-
# @param [String] from the string to start from
|
|
15
|
-
# @param [String] to the string to end at
|
|
16
|
-
#
|
|
17
|
-
# @return [Integer] the number of edits
|
|
18
|
-
#
|
|
19
|
-
# @api private
|
|
20
|
-
def self.levenshtein_distance(from, to)
|
|
21
|
-
row = (0..to.length).to_a
|
|
22
|
-
from.each_char.with_index(1) do |from_char, i|
|
|
23
|
-
next_levenshtein_row!(row, i, from_char, to)
|
|
24
|
-
end
|
|
25
|
-
row.fetch(-1)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Turn a row of the distance table into the next one, in place
|
|
29
|
-
#
|
|
30
|
-
# Cell j becomes the fewest edits that turn the first from_length
|
|
31
|
-
# characters of the from string into the first j characters of the to
|
|
32
|
-
# string.
|
|
33
|
-
#
|
|
34
|
-
# @param [Array<Integer>] row the row for the characters before from_char
|
|
35
|
-
# @param [Integer] from_length the number of from's characters, through
|
|
36
|
-
# from_char
|
|
37
|
-
# @param [String] from_char the from string's next character
|
|
38
|
-
# @param [String] to the string to end at
|
|
39
|
-
#
|
|
40
|
-
# @return [void]
|
|
41
|
-
#
|
|
42
|
-
# @api private
|
|
43
|
-
def self.next_levenshtein_row!(row, from_length, from_char, to)
|
|
44
|
-
diagonal = row.fetch(0)
|
|
45
|
-
row[0] = from_length
|
|
46
|
-
to.each_char.with_index(1) do |to_char, j|
|
|
47
|
-
above = row.fetch(j)
|
|
48
|
-
substitution = diagonal + (from_char.eql?(to_char) ? 0 : 1)
|
|
49
|
-
row[j] = [above + 1, row.fetch(j - 1) + 1, substitution].min
|
|
50
|
-
diagonal = above
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
private_class_method :next_levenshtein_row!
|
|
54
|
-
end
|
|
55
|
-
end
|