bluepill 0.2.9 → 0.3.2

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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -2
  3. data/README.md +16 -13
  4. data/bin/bluepill +21 -8
  5. data/bluepill.gemspec +7 -2
  6. data/lib/bluepill/application/lifecycle.rb +48 -35
  7. data/lib/bluepill/application/listener.rb +2 -4
  8. data/lib/bluepill/application/previous_daemon.rb +12 -14
  9. data/lib/bluepill/application.rb +36 -30
  10. data/lib/bluepill/base_directory.rb +18 -20
  11. data/lib/bluepill/check_registry.rb +104 -0
  12. data/lib/bluepill/clock.rb +1 -3
  13. data/lib/bluepill/condition_watch.rb +46 -54
  14. data/lib/bluepill/controller/directory.rb +1 -3
  15. data/lib/bluepill/controller.rb +35 -37
  16. data/lib/bluepill/daemonize.rb +52 -0
  17. data/lib/bluepill/dsl/app_proxy.rb +68 -64
  18. data/lib/bluepill/dsl/attributes.rb +135 -0
  19. data/lib/bluepill/dsl/process_factory/child_factory.rb +83 -0
  20. data/lib/bluepill/dsl/process_factory/registry.rb +4 -26
  21. data/lib/bluepill/dsl/process_factory.rb +85 -84
  22. data/lib/bluepill/dsl/process_proxy.rb +80 -160
  23. data/lib/bluepill/dsl.rb +16 -15
  24. data/lib/bluepill/errors.rb +190 -0
  25. data/lib/bluepill/group.rb +14 -37
  26. data/lib/bluepill/logger.rb +65 -99
  27. data/lib/bluepill/process/attributes.rb +66 -32
  28. data/lib/bluepill/process/children.rb +6 -7
  29. data/lib/bluepill/process/pid.rb +43 -35
  30. data/lib/bluepill/process/state_machine.rb +15 -59
  31. data/lib/bluepill/process/stop_signals.rb +123 -0
  32. data/lib/bluepill/process/transition.rb +1 -3
  33. data/lib/bluepill/process/transition_callbacks.rb +2 -16
  34. data/lib/bluepill/process/triggers.rb +90 -0
  35. data/lib/bluepill/process/user_commands.rb +1 -1
  36. data/lib/bluepill/process/watches.rb +9 -23
  37. data/lib/bluepill/process.rb +55 -52
  38. data/lib/bluepill/process_commands/execution.rb +16 -24
  39. data/lib/bluepill/process_commands/hooks.rb +1 -31
  40. data/lib/bluepill/process_commands/stop_signals.rb +12 -17
  41. data/lib/bluepill/process_commands.rb +10 -8
  42. data/lib/bluepill/process_conditions/always_true.rb +2 -6
  43. data/lib/bluepill/process_conditions/below_threshold.rb +6 -8
  44. data/lib/bluepill/process_conditions/cpu_usage.rb +1 -4
  45. data/lib/bluepill/process_conditions/file_time.rb +8 -9
  46. data/lib/bluepill/process_conditions/http.rb +29 -67
  47. data/lib/bluepill/process_conditions/mem_usage.rb +7 -45
  48. data/lib/bluepill/process_conditions/process_condition.rb +29 -47
  49. data/lib/bluepill/process_conditions/zombie_process.rb +2 -6
  50. data/lib/bluepill/process_conditions.rb +5 -14
  51. data/lib/bluepill/process_journal/cleanup.rb +5 -53
  52. data/lib/bluepill/process_journal/config.rb +73 -0
  53. data/lib/bluepill/process_journal/entries.rb +128 -0
  54. data/lib/bluepill/process_journal/journal.rb +69 -0
  55. data/lib/bluepill/process_journal/kind.rb +60 -0
  56. data/lib/bluepill/process_journal/lock.rb +9 -4
  57. data/lib/bluepill/process_journal.rb +13 -324
  58. data/lib/bluepill/process_statistics.rb +3 -7
  59. data/lib/bluepill/socket.rb +19 -17
  60. data/lib/bluepill/system/command_options.rb +136 -0
  61. data/lib/bluepill/system/command_result.rb +73 -0
  62. data/lib/bluepill/system/command_setup.rb +3 -4
  63. data/lib/bluepill/system/command_spawn.rb +244 -0
  64. data/lib/bluepill/system/commands.rb +27 -40
  65. data/lib/bluepill/system/daemon.rb +97 -15
  66. data/lib/bluepill/system/files.rb +35 -0
  67. data/lib/bluepill/system/ps.rb +20 -17
  68. data/lib/bluepill/system/ps_table.rb +7 -9
  69. data/lib/bluepill/system/usage.rb +175 -0
  70. data/lib/bluepill/system.rb +7 -192
  71. data/lib/bluepill/trigger.rb +18 -69
  72. data/lib/bluepill/triggers/flapping.rb +12 -8
  73. data/lib/bluepill/units.rb +7 -21
  74. data/lib/bluepill/version.rb +16 -26
  75. data/lib/bluepill.rb +1 -1
  76. data/sig/bluepill/application.rbs +11 -12
  77. data/sig/bluepill/attributes.rbs +48 -0
  78. data/sig/bluepill/checks.rbs +40 -40
  79. data/sig/bluepill/dsl.rbs +100 -59
  80. data/sig/bluepill/errors.rbs +48 -0
  81. data/sig/bluepill/logger.rbs +15 -31
  82. data/sig/bluepill/process.rbs +39 -305
  83. data/sig/bluepill/process_commands.rbs +235 -0
  84. data/sig/bluepill/stop_signals.rbs +21 -0
  85. data/sig/bluepill/system.rbs +191 -101
  86. data/sig/bluepill/version.rbs +17 -0
  87. data/sig/bluepill.rbs +2 -17
  88. data/sig/manifest.yaml +1 -0
  89. metadata +22 -8
  90. data/lib/bluepill/deprecation/custom_checks.rb +0 -193
  91. data/lib/bluepill/deprecation/dsl.rb +0 -141
  92. data/lib/bluepill/deprecation/options.rb +0 -140
  93. data/lib/bluepill/deprecation.rb +0 -92
  94. data/lib/bluepill/dsl/process_factory/children.rb +0 -99
  95. data/sig/bluepill/deprecation.rbs +0 -87
@@ -0,0 +1,48 @@
1
+ module Bluepill
2
+ # The options a config can set for a Process, and their defaults
3
+ module Process::Attributes
4
+ CONFIGURABLE_ATTRIBUTES: Array[Symbol]
5
+ APP_ATTRIBUTES: Array[Symbol]
6
+ CHILD_ATTRIBUTES: Array[Symbol]
7
+ NO_ENVIRONMENT: Hash[String, String]
8
+ DEFAULTS: Hash[Symbol, untyped]
9
+
10
+ attr_accessor pre_start_command: String?
11
+ attr_accessor start_command: String?
12
+ attr_accessor stop_command: String?
13
+ attr_accessor restart_command: String?
14
+ attr_accessor stdout: String?
15
+ attr_accessor stderr: String?
16
+ attr_accessor stdin: String?
17
+ attr_accessor daemonize: bool?
18
+ attr_accessor pid_file: String?
19
+ attr_accessor working_dir: String?
20
+ attr_accessor environment: Hash[_ToS, _ToS]?
21
+ attr_accessor start_grace_time: seconds
22
+ attr_accessor stop_grace_time: seconds
23
+ attr_accessor restart_grace_time: seconds
24
+ attr_accessor uid: String?
25
+ attr_accessor gid: String?
26
+ attr_accessor cache_actual_pid: bool
27
+ attr_accessor monitor_children: bool
28
+ attr_accessor child_process_factory: ProcessFactory::ChildFactory?
29
+ attr_accessor pid_command: String?
30
+ attr_accessor auto_start: bool?
31
+ attr_accessor supplementary_groups: Array[String]?
32
+ attr_reader stop_signals: Process::StopSignals?
33
+ # Takes signal names alternating with delays in seconds, too
34
+ def stop_signals=: (Process::StopSignals | Array[Symbol | Integer] | nil signals) -> Process::StopSignals?
35
+ attr_accessor on_start_timeout: Symbol
36
+ attr_accessor post_start_command: String?
37
+ attr_accessor pre_stop_command: String?
38
+ attr_accessor post_stop_command: String?
39
+ attr_accessor notify_command: String?
40
+ attr_accessor hook_timeout: seconds
41
+ attr_accessor group_start_noblock: bool
42
+ attr_accessor group_restart_noblock: bool
43
+ attr_accessor group_stop_noblock: bool
44
+ attr_accessor group_unmonitor_noblock: bool
45
+
46
+ def configure: (Hash[Symbol, untyped] options) -> void
47
+ end
48
+ end
@@ -1,17 +1,36 @@
1
1
  module Bluepill
2
+ # The checks and triggers a config can name, by their underscored class
3
+ # names
4
+ module CheckRegistry
5
+ # Each class, newest first, with the class it builds on and the methods
6
+ # it must define
7
+ self.@entries: Array[[Class, Class, Array[Symbol]]]
8
+
9
+ def self.add: (Class klass, Class base, Array[Symbol] required) -> void
10
+
11
+ def self.fetch: (Symbol | String name) -> Class
12
+
13
+ def self.names: () -> Array[String]
14
+
15
+ def self.check_name: (Class klass) -> String?
16
+
17
+ def self.missing_methods: (Class klass, Class base, Array[Symbol] required) -> Array[Symbol]
18
+
19
+ def self.unknown_message: (String name) -> String
20
+ end
21
+
2
22
  # Runs a process condition every so often, and fires its events when the
3
23
  # check fails often enough
4
24
  class ConditionWatch
5
25
  # A value the watch got, and whether it passed the check
6
26
  class HistoryValue < Struct[_ToS]
7
27
  attr_accessor value: _ToS
8
- attr_accessor critical: bool
28
+ attr_accessor passed: bool
9
29
 
10
- def self.new: (_ToS value, bool critical) -> HistoryValue
30
+ def self.new: (_ToS value, bool passed) -> HistoryValue
11
31
  end
12
32
 
13
33
  EMPTY_ARRAY: Array[Symbol]
14
- WATCH_KEYS: Array[Symbol]
15
34
 
16
35
  attr_reader logger: Logger
17
36
  attr_accessor name: Symbol
@@ -27,12 +46,11 @@ module Bluepill
27
46
  @process_condition: ProcessConditions::ProcessCondition[untyped]
28
47
  @last_ran_at: Integer?
29
48
 
30
- def initialize: (Symbol name, ?Hash[Symbol, untyped] options) -> void
49
+ def initialize: (Symbol name, ?logger: untyped, ?fires: untyped, ?every: untyped, ?times: untyped, ?include_children: bool, **untyped condition_options) -> void
31
50
 
32
- def create_condition: (Hash[Symbol, untyped] options) -> void
51
+ def events_to_fire: (Array[untyped] events) -> Array[Symbol]
33
52
 
34
- # Sets the logger of the watch and its condition
35
- def logger=: (Logger logger) -> void
53
+ def create_condition: (Hash[Symbol, untyped] options) -> void
36
54
 
37
55
  # Returns the events to fire
38
56
  def due?: (Integer tick_number) -> bool
@@ -52,25 +70,17 @@ module Bluepill
52
70
  class Trigger
53
71
  HALT: :halt
54
72
 
55
- self.@implementations: Hash[Symbol, singleton(Trigger)]
56
-
57
- def self.inherited: (singleton(Trigger) klass) -> void
58
-
59
- def self.[]: %a{implicitly-returns-nil} (Symbol name) -> singleton(Trigger)
73
+ REQUIRED_METHODS: Array[Symbol]
60
74
 
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
75
+ def self.inherited: (Class klass) -> void
63
76
 
64
77
  attr_accessor process: Process
65
78
  attr_reader logger: Logger
66
-
67
- # Sets the logger, and warns when code outside bluepill calls it
68
- def logger=: (Logger logger) -> void
69
79
  attr_reader scheduled_events: Array[[Symbol, Thread]]
70
80
 
71
81
  @reason: String
72
82
 
73
- def initialize: (Process process, ?Hash[Symbol, untyped] options) -> void
83
+ def initialize: (Process process, ?logger: untyped) -> void
74
84
 
75
85
  def reset!: () -> void
76
86
 
@@ -100,7 +110,7 @@ module Bluepill
100
110
  attr_accessor retry_in: Integer
101
111
  attr_reader timeline: Util::RotationalArray[Integer]
102
112
 
103
- def initialize: (Process process, ?Hash[Symbol, untyped] options) -> void
113
+ def initialize: (Process process, ?times: Integer, ?within: Integer, ?retry_in: Integer, **untyped options) -> void
104
114
 
105
115
  def notify: (_Transition transition) -> void
106
116
 
@@ -111,26 +121,22 @@ module Bluepill
111
121
  end
112
122
 
113
123
  module ProcessConditions
114
- def self.[]: (Symbol | String name) -> singleton(ProcessCondition)
115
-
116
124
  # Checks something about a process. V is the type of value that run
117
125
  # returns and check tests.
118
126
  class ProcessCondition[V]
119
- @options: Hash[Symbol, untyped]
127
+ REQUIRED_METHODS: Array[Symbol]
128
+
129
+ def self.inherited: (Class klass) -> void
120
130
 
121
131
  # The watch's logger
122
132
  attr_reader logger: Logger?
123
133
 
124
- # Sets the logger, and warns when code outside bluepill calls it
125
- def logger=: (Logger? logger) -> void
126
-
127
- def initialize: (?Hash[Symbol, untyped] options) -> void
134
+ def initialize: (?logger: Logger?) -> void
128
135
 
129
136
  def run: (Integer? pid, boolish include_children) -> V
130
137
 
131
138
  # Whether the value is fine
132
139
  def check?: (V value) -> bool
133
- def check: (V value) -> bool
134
140
 
135
141
  def format_value: (V value) -> V
136
142
  end
@@ -146,6 +152,8 @@ module Bluepill
146
152
  class BelowThreshold[V < Numeric] < ProcessCondition[V]
147
153
  @below: Numeric
148
154
 
155
+ def initialize: (below: Numeric, **untyped options) -> void
156
+
149
157
  def check?: (V value) -> bool
150
158
  end
151
159
 
@@ -158,6 +166,8 @@ module Bluepill
158
166
  class FileTime < BelowThreshold[Float]
159
167
  @filename: String
160
168
 
169
+ def initialize: (filename: String, below: Numeric, **untyped options) -> void
170
+
161
171
  def run: (Integer? pid, boolish include_children) -> (Float | StandardError | nil)
162
172
 
163
173
  def check?: (Float | StandardError | nil value) -> bool
@@ -171,33 +181,23 @@ module Bluepill
171
181
  @read_timeout: Integer
172
182
  @verify_ssl: boolish
173
183
 
184
+ def initialize: (url: String, ?kind: Integer | String | Symbol | nil, ?pattern: Regexp?, ?timeout: untyped, ?open_timeout: untyped, ?read_timeout: untyped, ?verify_ssl: boolish, **untyped options) -> void
185
+
174
186
  def run: (Integer? pid, boolish include_children) -> (Net::HTTPResponse | StandardError)
175
187
 
176
188
  def check?: (Net::HTTPResponse | StandardError value) -> bool
177
189
 
178
190
  private
179
191
 
180
- # Warns about an https check that doesn't set verify_ssl
181
- def warn_unverified: (Hash[Symbol, untyped] options) -> void
182
-
183
192
  def response_class: (untyped kind) -> Class
184
193
 
185
194
  def new_session: () -> Net::HTTP
186
-
187
- def hide_net_http_bug: [T] () { () -> T } -> T
188
195
  end
189
196
 
190
- # Memory usage in kilobytes
197
+ # Memory usage in bytes
191
198
  class MemUsage < BelowThreshold[Float]
192
- MB: Integer
193
- FORMAT_STR: String
194
- MB_LABEL: String
195
- KB_LABEL: String
196
-
197
199
  def run: (Integer? pid, boolish include_children) -> Float
198
200
 
199
- def check?: (Float value) -> bool
200
-
201
201
  def format_value: (Float value) -> String
202
202
  end
203
203
 
data/sig/bluepill/dsl.rbs CHANGED
@@ -1,46 +1,93 @@
1
1
  module Bluepill
2
+ # The parts the application and process blocks share
3
+ module DSL
4
+ # The attributes a pill file sets with `name = value`. The writers and
5
+ # readers are defined at load, and evaluate turns a call of an unknown
6
+ # one into a ConfigError.
7
+ module Attributes : _Owner
8
+ # What Attributes uses from the class that includes it
9
+ interface _Owner
10
+ def attribute_owner: () -> String
11
+
12
+ # The class, which extends ClassMethods
13
+ def class: () -> ClassMethods
14
+ end
15
+
16
+ def self.included: (Module base) -> void
17
+
18
+ # The attribute macro
19
+ module ClassMethods : Module
20
+ @attribute_names: Array[Symbol]
21
+
22
+ attr_reader attribute_names: Array[Symbol]
23
+
24
+ def attribute: (*Symbol names) -> void
25
+ end
26
+
27
+ @attributes: Hash[Symbol, untyped]
28
+
29
+ attr_reader attributes: Hash[Symbol, untyped]
30
+
31
+ def evaluate: () { (untyped proxy) [self: untyped] -> void } -> untyped
32
+
33
+ private
34
+
35
+ def unknown_attribute_message: (_ToS? name) -> String
36
+
37
+ def suggest: (String attribute) -> String?
38
+ end
39
+ end
40
+
2
41
  # self in an application block
3
42
  class AppProxy
4
- APP_ATTRIBUTES: Array[Symbol]
5
- NO_OPTIONS: Hash[Symbol, untyped]
6
-
7
- attr_accessor working_dir: String?
8
- attr_accessor uid: String?
9
- attr_accessor gid: String?
10
- attr_accessor supplementary_groups: Array[String]?
11
- attr_accessor environment: Hash[_ToS, _ToS]?
12
- attr_accessor auto_start: bool?
13
- attr_accessor notify_command: String?
43
+ include DSL::Attributes
44
+ extend DSL::Attributes::ClassMethods
45
+
46
+ def working_dir: () -> String?
47
+ def working_dir=: (String? value) -> String?
48
+ def uid: () -> String?
49
+ def uid=: (String? value) -> String?
50
+ def gid: () -> String?
51
+ def gid=: (String? value) -> String?
52
+ def supplementary_groups: () -> Array[String]?
53
+ def supplementary_groups=: (Array[String]? value) -> Array[String]?
54
+ def environment: () -> Hash[_ToS, _ToS]?
55
+ def environment=: (Hash[_ToS, _ToS]? value) -> Hash[_ToS, _ToS]?
56
+ def auto_start: () -> bool?
57
+ def auto_start=: (bool? value) -> bool?
58
+ def notify_command: () -> String?
59
+ def notify_command=: (String? value) -> String?
60
+
14
61
  attr_reader app: Application
15
62
 
63
+ @name: String
16
64
  @registry: ProcessFactory::Registry
17
65
 
18
- def initialize: (_ToS app_name, ?Hash[Symbol, untyped] options) -> void
66
+ def initialize: (_ToS app_name, **untyped options) -> void
19
67
 
20
68
  # The block runs with self set to the ProcessProxy, and also gets it as
21
69
  # an argument
22
70
  def process: (String process_name) { (ProcessProxy process) [self: ProcessProxy] -> void } -> Array[Process]
71
+
72
+ def attribute_owner: () -> String
23
73
  end
24
74
 
25
75
  # Builds processes from a process block in the config
26
76
  class ProcessFactory
27
- include Children
28
-
77
+ @attributes: Hash[Symbol, untyped]
29
78
  @process_block: process_block
30
79
  @registry: Registry
31
80
 
32
- attr_reader attributes: Hash[Symbol, untyped]
33
-
34
81
  def initialize: (Hash[Symbol, untyped] attributes, process_block process_block, ?Registry registry) -> void
35
82
 
36
83
  # The process, and the group its block set
37
- def create_process: (String name, String pids_dir) -> [Process, untyped]
84
+ def create_process: (String name, String pids_dir, logger: Logger) -> [Process, untyped]
38
85
 
39
86
  private
40
87
 
41
- def child_factory: (String name, Hash[Symbol, untyped] attributes, process_block child_process_block) -> ProcessFactory
88
+ def default_pid_file: (String process_name, String pids_dir) -> String
42
89
 
43
- def assign_default_pid_file: (Hash[Symbol, untyped] attributes, String process_name, String pids_dir) -> String?
90
+ def children_attributes: (ProcessProxy process) -> Hash[Symbol, untyped]
44
91
 
45
92
  def validate_process!: (ProcessProxy process) -> void
46
93
 
@@ -52,81 +99,75 @@ module Bluepill
52
99
 
53
100
  def validate_stop_signals!: (ProcessProxy process) -> void
54
101
 
55
- def validate_stop_signal_order!: (Array[Symbol | Integer] stop_signals) -> void
102
+ def validate_stop_grace_time!: (Process::StopSignals stop_signals, seconds? stop_grace_time) -> void
56
103
 
57
- def validate_stop_grace_time!: (Array[Symbol | Integer] stop_signals, Integer? stop_grace_time) -> void
104
+ def validate_on_start_timeout!: (ProcessProxy process) -> void
58
105
 
59
- def warn_unless_pid_known: (ProcessProxy process, String? default_pid_file) -> void
106
+ def warn_unless_pid_known: (ProcessProxy process, String default_pid_file) -> void
60
107
 
61
108
  def config_error!: (String message) -> bot
62
109
 
63
110
  # The process names and pid files an application's config has used
64
111
  class Registry
65
- @process_keys: Hash[Array[String?], nil]
66
- @pid_files: Hash[String, nil]
112
+ @process_keys: Set[[String?, String]]
113
+ @pid_files: Set[String]
67
114
 
68
115
  def initialize: () -> void
69
116
 
70
117
  def add_process?: (_ToS? group, _ToS name) -> bool
71
118
 
72
119
  def add_pid_file?: (String pid_file) -> bool
73
-
74
- private
75
-
76
- def add?: [K < Hash::_Key] (Hash[K, nil] keys, K key) -> bool
77
120
  end
78
121
 
79
- # Creates the processes of a process's children, for ProcessFactory,
80
- # which is the only class that includes it
81
- module Children
122
+ # Creates the processes of a process's children, and checks their
123
+ # block when it's made
124
+ class ChildFactory
82
125
  @attributes: Hash[Symbol, untyped]
83
- @process_block: process_block
126
+ @child_process_block: process_block
84
127
 
85
- def create_child_process: (String name, Integer pid, Logger logger) -> Process
128
+ def initialize: (String parent_name, Hash[Symbol, untyped] parent_attributes, process_block child_process_block) -> void
86
129
 
87
- # Warns about what 0.3.0 rejects in the children's block
88
- def check_children: (String parent_name) -> void
130
+ def create_child_process: (String name, Integer pid, Logger logger) -> Process
89
131
 
90
132
  private
91
133
 
92
- def inherited_attributes: () -> Hash[Symbol, untyped]
93
-
94
- def validate_child_process!: (ProcessProxy child) -> void
134
+ def validate!: (String parent_name) -> void
95
135
  end
96
136
  end
97
137
 
98
- # self in a process block. Any attribute can be set with `name = value`,
99
- # `name value` or `name!` (for true), and read back with `name`.
138
+ # self in a process block. Each attribute is set with `name = value`
139
+ # and read back with `name`. The writers and readers are defined at load,
140
+ # from Process::CONFIGURABLE_ATTRIBUTES, so they aren't listed here.
100
141
  class ProcessProxy
101
- attr_reader attributes: Hash[Symbol, untyped]
102
- attr_reader watches: Hash[Symbol, Hash[Symbol, untyped]]
103
- attr_reader name: String
104
-
105
- def initialize: (String process_name, Hash[Symbol, untyped] attributes, process_block process_block) -> void
106
-
107
- # Sets or reads an attribute
108
- def method_missing: (Symbol name, *untyped args) -> untyped
142
+ include DSL::Attributes
143
+ extend DSL::Attributes::ClassMethods
109
144
 
110
- def respond_to_missing?: (Symbol name, bool? include_private) -> bool
145
+ PRIVILEGE_ATTRIBUTES: Array[Symbol]
111
146
 
112
- # Whether a config can set the attribute on a process
113
- def self.attribute?: (Symbol name) -> bool
147
+ def validate_privileges!: () -> void
114
148
 
115
- def self.attribute_names: () -> Array[Symbol]
149
+ attr_reader name: String
150
+ attr_reader child_process_block: process_block?
151
+ attr_reader actual_pid: Integer?
116
152
 
117
- def checks: (Symbol name, ?Hash[Symbol, untyped]? options, **untyped keywords) -> Hash[Symbol, untyped]
153
+ # The checks the block added, in order, with their options
154
+ @checks: Array[[Symbol, Hash[Symbol, untyped]]]
118
155
 
119
- # The block configures the children like a process block
120
- def monitor_children: () ?{ (ProcessProxy child) [self: ProcessProxy] -> void } -> process_block?
156
+ def initialize: (String process_name, Hash[Symbol, untyped] attributes, process_block process_block, ?actual_pid: Integer?) -> void
121
157
 
122
- def to_process: () -> Process
158
+ # The readers of the attributes the factory uses
159
+ def group: () -> untyped
160
+ def pid_file: () -> String?
161
+ def stop_command: () -> String?
162
+ def on_start_timeout: () -> untyped
123
163
 
124
- private
164
+ def checks: (Symbol name, **untyped options) -> nil
125
165
 
126
- def attribute_call: (Symbol name, Array[untyped] args) -> ([Symbol, bool] | [Symbol, bool, untyped])?
166
+ # The block configures the children like a process block
167
+ def monitor_children: () ?{ (ProcessProxy child) [self: ProcessProxy] -> void } -> process_block
127
168
 
128
- def unknown_attribute!: (Symbol key) -> bot
169
+ def to_process: (**untyped options) -> Process
129
170
 
130
- def suggest: (Symbol key) -> String?
171
+ def attribute_owner: () -> String
131
172
  end
132
173
  end
@@ -0,0 +1,48 @@
1
+ module Bluepill
2
+ # An error that stops the bluepill command, with the status it exits with
3
+ class Error < StandardError
4
+ def exit_status: () -> Integer
5
+ end
6
+
7
+ # A mistake in a pill file
8
+ class ConfigError < Error
9
+ LIBRARY_DIR: String
10
+
11
+ def location: () -> String?
12
+
13
+ private
14
+
15
+ def outside_library?: (Thread::Backtrace::Location frame) -> bool
16
+ end
17
+
18
+ # The daemon couldn't start
19
+ class StartupError < Error
20
+ end
21
+
22
+ # A previous daemon for the application couldn't be stopped
23
+ class PreviousDaemonError < Error
24
+ end
25
+
26
+ # A daemon for the application is already running
27
+ class AlreadyRunningError < Error
28
+ end
29
+
30
+ # The CLI couldn't reach the daemon
31
+ class ConnectionError < Error
32
+ end
33
+
34
+ # The daemon runs another version of bluepill
35
+ class VersionMismatchError < Error
36
+ end
37
+
38
+ # The CLI was given a command it doesn't know
39
+ class UnknownCommandError < Error
40
+ end
41
+
42
+ # The daemon answered a command with an error
43
+ class DaemonError < Error
44
+ attr_reader daemon_error: Exception
45
+
46
+ def initialize: (Exception daemon_error) -> void
47
+ end
48
+ end
@@ -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
- @options: options
53
- @logger: Logger | (Object & _Backend)
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: (?options options) -> void
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, ?Array[String?]? prefix) -> void
55
+ def emerg: (_ToS msg) -> void
65
56
 
66
- def alert: (_ToS msg, ?Array[String?]? prefix) -> void
57
+ def alert: (_ToS msg) -> void
67
58
 
68
- def crit: (_ToS msg, ?Array[String?]? prefix) -> void
59
+ def crit: (_ToS msg) -> void
69
60
 
70
- def err: (_ToS msg, ?Array[String?]? prefix) -> void
61
+ def err: (_ToS msg) -> void
71
62
 
72
- def warning: (_ToS msg, ?Array[String?]? prefix) -> void
63
+ def warning: (_ToS msg) -> void
73
64
 
74
- def notice: (_ToS msg, ?Array[String?]? prefix) -> void
65
+ def notice: (_ToS msg) -> void
75
66
 
76
- def info: (_ToS msg, ?Array[String?]? prefix) -> void
67
+ def info: (_ToS msg) -> void
77
68
 
78
- def debug: (_ToS msg, ?Array[String?]? prefix) -> void
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
- attr_reader level: Integer
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