bluepill 0.2.9 → 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 +100 -2
- data/README.md +12 -7
- data/bin/bluepill +8 -2
- data/bluepill.gemspec +1 -1
- data/lib/bluepill/application/lifecycle.rb +44 -34
- data/lib/bluepill/application/listener.rb +1 -1
- data/lib/bluepill/application/previous_daemon.rb +12 -14
- data/lib/bluepill/application.rb +33 -29
- 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 +45 -54
- data/lib/bluepill/controller/directory.rb +1 -3
- data/lib/bluepill/controller.rb +32 -37
- data/lib/bluepill/dsl/app_proxy.rb +68 -64
- 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 +83 -84
- data/lib/bluepill/dsl/process_proxy.rb +61 -168
- data/lib/bluepill/dsl.rb +16 -15
- 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 -16
- 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 +55 -52
- 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 -67
- data/lib/bluepill/process_conditions/mem_usage.rb +7 -45
- data/lib/bluepill/process_conditions/process_condition.rb +29 -47
- 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 +18 -69
- data/lib/bluepill/triggers/flapping.rb +12 -8
- data/lib/bluepill/units.rb +7 -21
- data/lib/bluepill/version.rb +12 -22
- data/lib/bluepill.rb +1 -1
- data/sig/bluepill/application.rbs +11 -12
- data/sig/bluepill/attributes.rbs +48 -0
- data/sig/bluepill/checks.rbs +40 -40
- data/sig/bluepill/dsl.rbs +97 -60
- data/sig/bluepill/errors.rbs +48 -0
- data/sig/bluepill/logger.rbs +15 -31
- data/sig/bluepill/process.rbs +39 -305
- 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 +1 -17
- data/sig/manifest.yaml +1 -0
- metadata +21 -8
- data/lib/bluepill/deprecation/custom_checks.rb +0 -193
- data/lib/bluepill/deprecation/dsl.rb +0 -141
- data/lib/bluepill/deprecation/options.rb +0 -140
- data/lib/bluepill/deprecation.rb +0 -92
- data/lib/bluepill/dsl/process_factory/children.rb +0 -99
- data/sig/bluepill/deprecation.rbs +0 -87
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bluepill
|
|
4
|
-
class ProcessFactory
|
|
5
|
-
# Create the processes of the children that a process's factory finds
|
|
6
|
-
#
|
|
7
|
-
# A process that monitors its children gets a factory of its own, with
|
|
8
|
-
# the process block that configures each child. Process asks it for a
|
|
9
|
-
# child's process when it finds a new child.
|
|
10
|
-
#
|
|
11
|
-
# @api private
|
|
12
|
-
module Children
|
|
13
|
-
# Create the process of a child that bluepill found
|
|
14
|
-
#
|
|
15
|
-
# The child gets its parent's grace times, the parent's user and groups,
|
|
16
|
-
# so its commands run as the parent's do, and its state from whether
|
|
17
|
-
# it's running.
|
|
18
|
-
#
|
|
19
|
-
# @param [String] name the child's name
|
|
20
|
-
# @param [Integer] pid the child's pid
|
|
21
|
-
# @param [Logger] logger the child's logger
|
|
22
|
-
#
|
|
23
|
-
# @return [Process] the child's process
|
|
24
|
-
#
|
|
25
|
-
# @api private
|
|
26
|
-
def create_child_process(name, pid, logger)
|
|
27
|
-
attributes = inherited_attributes
|
|
28
|
-
attributes[:actual_pid] = pid
|
|
29
|
-
attributes[:logger] = logger
|
|
30
|
-
|
|
31
|
-
child = ProcessProxy.new(name, attributes, @process_block)
|
|
32
|
-
validate_child_process! child
|
|
33
|
-
process = child.to_process
|
|
34
|
-
|
|
35
|
-
process.determine_initial_state
|
|
36
|
-
process
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Warn about what 0.3.0 rejects in the children's block
|
|
40
|
-
#
|
|
41
|
-
# It runs while the pill file loads.
|
|
42
|
-
#
|
|
43
|
-
# Bluepill 0.3.0 runs the block once when the pill file loads, for a
|
|
44
|
-
# child whose pid isn't known yet, and fails the config for a mistake
|
|
45
|
-
# in it, such as a missing stop_command, where 0.2 exits the daemon
|
|
46
|
-
# the first time it finds a child. This runs the block the same way,
|
|
47
|
-
# to warn about the mistakes and about the checks that the children
|
|
48
|
-
# get. A block that raises for such a child, or no block, which
|
|
49
|
-
# monitor_children has warned about, warns about nothing.
|
|
50
|
-
#
|
|
51
|
-
# @param [String] parent_name the parent process's name
|
|
52
|
-
#
|
|
53
|
-
# @return [void]
|
|
54
|
-
#
|
|
55
|
-
# @api private
|
|
56
|
-
def check_children(parent_name)
|
|
57
|
-
child = ProcessProxy.new("<child of #{parent_name}>", inherited_attributes, @process_block)
|
|
58
|
-
Deprecation.check_on_start_timeout(child.name, child.attributes)
|
|
59
|
-
Deprecation.check_child_stop_command(parent_name, child.attributes)
|
|
60
|
-
child.to_process
|
|
61
|
-
rescue
|
|
62
|
-
nil
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
protected
|
|
66
|
-
|
|
67
|
-
# Return the attributes a child gets from its parent
|
|
68
|
-
#
|
|
69
|
-
# These are the grace times, user and groups that the parent sets.
|
|
70
|
-
#
|
|
71
|
-
# @return [Hash{Symbol => Object}] the attributes
|
|
72
|
-
#
|
|
73
|
-
# @api private
|
|
74
|
-
def inherited_attributes
|
|
75
|
-
attributes = {} #: Hash[Symbol, untyped]
|
|
76
|
-
# A grace time the parent leaves unset keeps the Process default
|
|
77
|
-
%i[start_grace_time stop_grace_time restart_grace_time uid gid supplementary_groups].each do |a|
|
|
78
|
-
attributes[a] = @attributes.fetch(a) if @attributes.key?(a)
|
|
79
|
-
end
|
|
80
|
-
attributes
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Exit unless a monitored child has a stop_command
|
|
84
|
-
#
|
|
85
|
-
# @param [ProcessProxy] child the child's proxy
|
|
86
|
-
#
|
|
87
|
-
# @return [void]
|
|
88
|
-
#
|
|
89
|
-
# @api private
|
|
90
|
-
def validate_child_process!(child)
|
|
91
|
-
return if child.attributes.key?(:stop_command)
|
|
92
|
-
|
|
93
|
-
$stderr.puts "Config Error: Invalid child process monitor for #{child.name}"
|
|
94
|
-
$stderr.puts "You must specify a stop command to monitor child processes."
|
|
95
|
-
exit(6)
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|