bluepill 0.1.6 → 0.1.7
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 +31 -1
- data/README.md +19 -2
- data/lib/bluepill/application.rb +6 -3
- data/lib/bluepill/clock.rb +48 -0
- data/lib/bluepill/condition_watch.rb +31 -17
- data/lib/bluepill/controller.rb +32 -8
- data/lib/bluepill/deprecation.rb +74 -0
- data/lib/bluepill/dsl/process_factory.rb +60 -0
- data/lib/bluepill/dsl/process_proxy.rb +41 -2
- data/lib/bluepill/dsl.rb +23 -0
- data/lib/bluepill/process.rb +23 -17
- data/lib/bluepill/process_commands.rb +3 -3
- data/lib/bluepill/process_conditions/http.rb +29 -4
- data/lib/bluepill/trigger/custom.rb +147 -0
- data/lib/bluepill/trigger.rb +1 -2
- data/lib/bluepill/triggers/flapping.rb +1 -1
- data/lib/bluepill/util/log_error.rb +29 -0
- data/lib/bluepill/version.rb +7 -7
- data/lib/bluepill.rb +5 -0
- data/sig/bluepill.rbs +125 -4
- metadata +5 -1
data/sig/bluepill.rbs
CHANGED
|
@@ -20,6 +20,47 @@ module Bluepill
|
|
|
20
20
|
# the AppProxy, and also gets it as an argument.
|
|
21
21
|
def self.application: (_ToS app_name, ?Hash[Symbol, untyped] options) { (AppProxy app) [self: AppProxy] -> void } -> void
|
|
22
22
|
|
|
23
|
+
# Warns on a Ruby that bluepill 0.2 doesn't run on
|
|
24
|
+
def self.warn_unsupported_ruby: (?String ruby_version, ?String? jruby_version) -> void
|
|
25
|
+
|
|
26
|
+
# Times ticks, checks, grace times and flapping with the monotonic clock,
|
|
27
|
+
# or the system clock on a Ruby without Process.clock_gettime
|
|
28
|
+
module Clock
|
|
29
|
+
# The module that reader reads the clock with: Process, or a stand-in
|
|
30
|
+
interface _ClockSource
|
|
31
|
+
def respond_to?: (Symbol name) -> bool
|
|
32
|
+
|
|
33
|
+
def clock_gettime: (Integer clock_id) -> Float
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.reader: (?_ClockSource process) -> ^() -> Integer
|
|
37
|
+
|
|
38
|
+
READER: ^() -> Integer
|
|
39
|
+
|
|
40
|
+
def self.now: () -> Integer
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Warns, once each, about what a later version of bluepill will change
|
|
44
|
+
module Deprecation
|
|
45
|
+
self.@warned: Hash[untyped, bool]
|
|
46
|
+
self.@mutex: Thread::Mutex
|
|
47
|
+
self.@logger: Logger?
|
|
48
|
+
|
|
49
|
+
# The logger warnings also go to, which the application sets
|
|
50
|
+
def self.logger: () -> Logger?
|
|
51
|
+
|
|
52
|
+
def self.logger=: (Logger? logger) -> Logger?
|
|
53
|
+
|
|
54
|
+
# Writes "DEPRECATION: message" to stderr and the logger, the first time
|
|
55
|
+
# for a key
|
|
56
|
+
def self.warn: (untyped key, String message) -> bool
|
|
57
|
+
|
|
58
|
+
def self.first?: (untyped key) -> bool
|
|
59
|
+
|
|
60
|
+
# Forgets the warnings given, and the logger
|
|
61
|
+
def self.reset!: () -> void
|
|
62
|
+
end
|
|
63
|
+
|
|
23
64
|
module Version
|
|
24
65
|
def self.major: () -> Integer
|
|
25
66
|
|
|
@@ -82,7 +123,8 @@ module Bluepill
|
|
|
82
123
|
|
|
83
124
|
def add_process: (Process process, ?_ToS? group_name) -> Array[Process]
|
|
84
125
|
|
|
85
|
-
|
|
126
|
+
# The version as a String, which Marshal sends whole
|
|
127
|
+
def version: () -> String
|
|
86
128
|
|
|
87
129
|
# Ruby's protected methods are private in RBS
|
|
88
130
|
|
|
@@ -113,6 +155,12 @@ module Bluepill
|
|
|
113
155
|
|
|
114
156
|
# Runs the bluepill commands, and sends them to the daemon over its socket
|
|
115
157
|
class Controller
|
|
158
|
+
TAIL_COMMAND: String
|
|
159
|
+
|
|
160
|
+
OUT_OF_DATE: String
|
|
161
|
+
|
|
162
|
+
UNKNOWN_VERSION: String
|
|
163
|
+
|
|
116
164
|
attr_accessor base_dir: String
|
|
117
165
|
attr_accessor log_file: String?
|
|
118
166
|
attr_accessor sockets_dir: String
|
|
@@ -234,7 +282,7 @@ module Bluepill
|
|
|
234
282
|
|
|
235
283
|
attr_accessor name: String
|
|
236
284
|
attr_accessor watches: Array[ConditionWatch]
|
|
237
|
-
attr_accessor triggers: Array[Trigger]
|
|
285
|
+
attr_accessor triggers: Array[Trigger | Trigger::Custom]
|
|
238
286
|
attr_accessor skip_ticks_until: Integer?
|
|
239
287
|
attr_accessor process_running: bool?
|
|
240
288
|
|
|
@@ -362,11 +410,12 @@ module Bluepill
|
|
|
362
410
|
|
|
363
411
|
def record_transition: (_Transition transition) -> void
|
|
364
412
|
|
|
365
|
-
def notify_triggers: (_Transition transition) -> void
|
|
413
|
+
def notify_triggers: (_Transition & Object transition) -> void
|
|
366
414
|
|
|
367
415
|
def add_watch: (Symbol name, Hash[Symbol, untyped] options) -> Array[ConditionWatch]
|
|
368
416
|
|
|
369
|
-
|
|
417
|
+
# Wraps a trigger that a config defines in a Trigger::Custom
|
|
418
|
+
def add_trigger: (Symbol name, Hash[Symbol, untyped] options) -> Array[Trigger | Trigger::Custom]
|
|
370
419
|
|
|
371
420
|
def run_watches: () -> void
|
|
372
421
|
|
|
@@ -566,6 +615,9 @@ module Bluepill
|
|
|
566
615
|
# Returns the events to fire
|
|
567
616
|
def run: (Integer? pid, ?Integer tick_number) -> Array[Symbol]
|
|
568
617
|
|
|
618
|
+
# Logs an error the check raised, which skips it until its next run
|
|
619
|
+
def check_failed: (StandardError error) -> void
|
|
620
|
+
|
|
569
621
|
def clear_history!: () -> Util::RotationalArray[HistoryValue]
|
|
570
622
|
|
|
571
623
|
def fired?: () -> bool
|
|
@@ -598,6 +650,40 @@ module Bluepill
|
|
|
598
650
|
def schedule_event: (Symbol event, seconds delay) -> Thread
|
|
599
651
|
|
|
600
652
|
def cancel_all_events: () -> void
|
|
653
|
+
|
|
654
|
+
# A trigger that a config defines, which gets transitions that warn
|
|
655
|
+
# about what bluepill 0.2.0's lack
|
|
656
|
+
class Custom
|
|
657
|
+
attr_reader trigger: Trigger
|
|
658
|
+
|
|
659
|
+
def initialize: (Trigger trigger) -> void
|
|
660
|
+
|
|
661
|
+
# state_machine's transition, which is an Object
|
|
662
|
+
def notify: (_Transition & Object transition) -> void
|
|
663
|
+
|
|
664
|
+
def reset!: () -> void
|
|
665
|
+
|
|
666
|
+
def logger=: (Logger logger) -> void
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
# A transition that warns about anything but from_name, to_name and
|
|
670
|
+
# loopback?, which are all that bluepill 0.2.0's have
|
|
671
|
+
class Transition
|
|
672
|
+
@transition: _Transition & Object
|
|
673
|
+
@trigger_class: Class
|
|
674
|
+
|
|
675
|
+
def initialize: (_Transition & Object transition, Class trigger_class) -> void
|
|
676
|
+
|
|
677
|
+
def from_name: () -> Symbol?
|
|
678
|
+
|
|
679
|
+
def to_name: () -> Symbol?
|
|
680
|
+
|
|
681
|
+
def loopback?: () -> bool
|
|
682
|
+
|
|
683
|
+
def method_missing: (Symbol name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
|
|
684
|
+
|
|
685
|
+
def respond_to_missing?: (Symbol name, bool include_private) -> bool
|
|
686
|
+
end
|
|
601
687
|
end
|
|
602
688
|
|
|
603
689
|
module Triggers
|
|
@@ -642,6 +728,14 @@ module Bluepill
|
|
|
642
728
|
|
|
643
729
|
# Builds processes from a process block in the config
|
|
644
730
|
class ProcessFactory
|
|
731
|
+
PRE_START_COMMAND: String
|
|
732
|
+
|
|
733
|
+
UID_WITHOUT_GID: String
|
|
734
|
+
|
|
735
|
+
UID_WITH_GID: String
|
|
736
|
+
|
|
737
|
+
CHILDREN_USER: String
|
|
738
|
+
|
|
645
739
|
@@process_keys: Hash[Array[String?], nil]
|
|
646
740
|
@@pid_files: Hash[String, nil]
|
|
647
741
|
|
|
@@ -671,6 +765,13 @@ module Bluepill
|
|
|
671
765
|
|
|
672
766
|
def warn_unless_pid_known: (ProcessProxy process, String? default_pid_file) -> void
|
|
673
767
|
|
|
768
|
+
# Warns about what bluepill 0.2.0 does differently with the process
|
|
769
|
+
def warn_of_0_2_changes: () -> void
|
|
770
|
+
|
|
771
|
+
# Warns, as root, that 0.2.0 runs a process with a uid in the user's
|
|
772
|
+
# groups
|
|
773
|
+
def warn_of_0_2_groups: () -> void
|
|
774
|
+
|
|
674
775
|
def config_error!: (String message) -> bot
|
|
675
776
|
|
|
676
777
|
def validate_child_process!: (ProcessProxy child) -> void
|
|
@@ -679,6 +780,12 @@ module Bluepill
|
|
|
679
780
|
# self in a process block. Any attribute can be set with `name = value`,
|
|
680
781
|
# `name value` or `name!` (for true), and read back with `name`.
|
|
681
782
|
class ProcessProxy
|
|
783
|
+
ATTRIBUTES_ADDED_IN_0_2: Array[Symbol]
|
|
784
|
+
|
|
785
|
+
# Whether bluepill 0.2.0 knows a process attribute, which it fails the
|
|
786
|
+
# config without
|
|
787
|
+
def self.known_in_0_2?: (Symbol name) -> bool
|
|
788
|
+
|
|
682
789
|
attr_reader attributes: Hash[Symbol, untyped]
|
|
683
790
|
attr_reader watches: Hash[Symbol, Hash[Symbol, untyped]]
|
|
684
791
|
attr_reader name: String
|
|
@@ -696,6 +803,11 @@ module Bluepill
|
|
|
696
803
|
def monitor_children: () ?{ (ProcessProxy child) [self: ProcessProxy] -> void } -> process_block?
|
|
697
804
|
|
|
698
805
|
def to_process: () -> Process
|
|
806
|
+
|
|
807
|
+
private
|
|
808
|
+
|
|
809
|
+
# Sets an attribute, and warns about one that 0.2.0 doesn't know
|
|
810
|
+
def set_attribute: (Symbol key, untyped value) -> untyped
|
|
699
811
|
end
|
|
700
812
|
|
|
701
813
|
# Memoizes ps output for a tick, and runs commands as daemons or until
|
|
@@ -887,6 +999,7 @@ module Bluepill
|
|
|
887
999
|
@pattern: Regexp?
|
|
888
1000
|
@open_timeout: Integer
|
|
889
1001
|
@read_timeout: Integer
|
|
1002
|
+
@verify_ssl: boolish
|
|
890
1003
|
|
|
891
1004
|
def run: (Integer? pid, boolish include_children) -> (Net::HTTPResponse | StandardError)
|
|
892
1005
|
|
|
@@ -894,6 +1007,10 @@ module Bluepill
|
|
|
894
1007
|
|
|
895
1008
|
private
|
|
896
1009
|
|
|
1010
|
+
# Warns that 0.3.0 verifies the certificate of an https URL that
|
|
1011
|
+
# doesn't set verify_ssl
|
|
1012
|
+
def warn_unverified: () -> void
|
|
1013
|
+
|
|
897
1014
|
def hide_net_http_bug: [T] () { () -> T } -> T
|
|
898
1015
|
end
|
|
899
1016
|
|
|
@@ -931,6 +1048,10 @@ module Bluepill
|
|
|
931
1048
|
end
|
|
932
1049
|
|
|
933
1050
|
module Util
|
|
1051
|
+
# Logs an error at err, a line for its summary and one for each line of
|
|
1052
|
+
# its backtrace
|
|
1053
|
+
def self.log_error: (Logger logger, String summary, Exception error) -> void
|
|
1054
|
+
|
|
934
1055
|
# An array that drops its oldest element when it grows past its capacity
|
|
935
1056
|
class RotationalArray[Elem] < Array[Elem]
|
|
936
1057
|
@capacity: Integer
|
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.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arya Asemanfar
|
|
@@ -76,8 +76,10 @@ files:
|
|
|
76
76
|
- bluepill.gemspec
|
|
77
77
|
- lib/bluepill.rb
|
|
78
78
|
- lib/bluepill/application.rb
|
|
79
|
+
- lib/bluepill/clock.rb
|
|
79
80
|
- lib/bluepill/condition_watch.rb
|
|
80
81
|
- lib/bluepill/controller.rb
|
|
82
|
+
- lib/bluepill/deprecation.rb
|
|
81
83
|
- lib/bluepill/dsl.rb
|
|
82
84
|
- lib/bluepill/dsl/app_proxy.rb
|
|
83
85
|
- lib/bluepill/dsl/process_factory.rb
|
|
@@ -101,7 +103,9 @@ files:
|
|
|
101
103
|
- lib/bluepill/system.rb
|
|
102
104
|
- lib/bluepill/system/commands.rb
|
|
103
105
|
- lib/bluepill/trigger.rb
|
|
106
|
+
- lib/bluepill/trigger/custom.rb
|
|
104
107
|
- lib/bluepill/triggers/flapping.rb
|
|
108
|
+
- lib/bluepill/util/log_error.rb
|
|
105
109
|
- lib/bluepill/util/rotational_array.rb
|
|
106
110
|
- lib/bluepill/version.rb
|
|
107
111
|
- sig/bluepill.rbs
|