bluepill 0.1.7 → 0.2.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 +40 -21
- data/CONTRIBUTING.md +2 -2
- data/README.md +100 -20
- data/bin/bluepill +25 -30
- data/bluepill.gemspec +21 -28
- data/lib/bluepill/application/lifecycle.rb +166 -0
- data/lib/bluepill/application/listener.rb +124 -0
- data/lib/bluepill/application/previous_daemon.rb +81 -0
- data/lib/bluepill/application.rb +59 -259
- data/lib/bluepill/base_directory.rb +93 -0
- data/lib/bluepill/condition_watch.rb +129 -65
- data/lib/bluepill/controller/directory.rb +59 -0
- data/lib/bluepill/controller.rb +99 -118
- data/lib/bluepill/daemonize.rb +234 -0
- data/lib/bluepill/dsl/app_proxy.rb +30 -6
- data/lib/bluepill/dsl/process_factory/children.rb +71 -0
- data/lib/bluepill/dsl/process_factory/registry.rb +69 -0
- data/lib/bluepill/dsl/process_factory.rb +81 -152
- data/lib/bluepill/dsl/process_proxy.rb +100 -51
- data/lib/bluepill/dsl.rb +0 -23
- data/lib/bluepill/group.rb +187 -78
- data/lib/bluepill/logger.rb +139 -48
- data/lib/bluepill/pid_file.rb +23 -0
- data/lib/bluepill/process/attributes.rb +379 -0
- data/lib/bluepill/process/children.rb +70 -0
- data/lib/bluepill/process/pid.rb +154 -0
- data/lib/bluepill/process/state_machine.rb +196 -0
- data/lib/bluepill/process/transition.rb +45 -0
- data/lib/bluepill/process/transition_callbacks.rb +101 -0
- data/lib/bluepill/process/user_commands.rb +71 -0
- data/lib/bluepill/process/watches.rb +141 -0
- data/lib/bluepill/process.rb +64 -667
- data/lib/bluepill/process_commands/execution.rb +89 -0
- data/lib/bluepill/process_commands/hooks.rb +186 -0
- data/lib/bluepill/process_commands/stop_signals.rb +114 -0
- data/lib/bluepill/process_commands.rb +106 -174
- data/lib/bluepill/process_conditions/always_true.rb +1 -1
- data/lib/bluepill/process_conditions/below_threshold.rb +36 -0
- data/lib/bluepill/process_conditions/cpu_usage.rb +1 -25
- data/lib/bluepill/process_conditions/file_time.rb +4 -5
- data/lib/bluepill/process_conditions/http.rb +48 -45
- data/lib/bluepill/process_conditions/mem_usage.rb +9 -22
- data/lib/bluepill/process_conditions/process_condition.rb +34 -3
- data/lib/bluepill/process_conditions/running_time.rb +1 -25
- data/lib/bluepill/process_conditions/zombie_process.rb +1 -1
- data/lib/bluepill/process_conditions.rb +3 -2
- data/lib/bluepill/process_journal/cleanup.rb +200 -0
- data/lib/bluepill/process_journal/lock.rb +106 -0
- data/lib/bluepill/process_journal.rb +126 -233
- data/lib/bluepill/process_statistics.rb +2 -2
- data/lib/bluepill/socket.rb +60 -20
- data/lib/bluepill/system/command_setup.rb +98 -0
- data/lib/bluepill/system/commands.rb +219 -248
- data/lib/bluepill/system/daemon.rb +161 -0
- data/lib/bluepill/system/ps.rb +85 -0
- data/lib/bluepill/system/ps_table.rb +163 -0
- data/lib/bluepill/system.rb +45 -126
- data/lib/bluepill/trigger.rb +52 -25
- data/lib/bluepill/triggers/flapping.rb +8 -16
- data/lib/bluepill/units.rb +126 -0
- data/lib/bluepill/util/inflections.rb +34 -0
- data/lib/bluepill/util/levenshtein.rb +53 -0
- data/lib/bluepill/util/rotational_array.rb +1 -1
- data/lib/bluepill/version.rb +13 -12
- data/lib/bluepill.rb +27 -35
- data/sig/bluepill/application.rbs +257 -0
- data/sig/bluepill/checks.rbs +203 -0
- data/sig/bluepill/dsl.rbs +126 -0
- data/sig/bluepill/logger.rbs +104 -0
- data/sig/bluepill/process.rbs +542 -0
- data/sig/bluepill/system.rbs +316 -0
- data/sig/bluepill.rbs +47 -994
- metadata +39 -49
- data/lib/bluepill/clock.rb +0 -48
- data/lib/bluepill/deprecation.rb +0 -74
- data/lib/bluepill/trigger/custom.rb +0 -147
- data/lib/bluepill/util/log_error.rb +0 -29
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.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arya Asemanfar
|
|
@@ -11,49 +11,7 @@ authors:
|
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
13
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
|
-
dependencies:
|
|
15
|
-
- !ruby/object:Gem::Dependency
|
|
16
|
-
name: activesupport
|
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
|
18
|
-
requirements:
|
|
19
|
-
- - ">="
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: '3.2'
|
|
22
|
-
type: :runtime
|
|
23
|
-
prerelease: false
|
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
requirements:
|
|
26
|
-
- - ">="
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
version: '3.2'
|
|
29
|
-
- !ruby/object:Gem::Dependency
|
|
30
|
-
name: blue-daemons
|
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
|
32
|
-
requirements:
|
|
33
|
-
- - "~>"
|
|
34
|
-
- !ruby/object:Gem::Version
|
|
35
|
-
version: '1.1'
|
|
36
|
-
type: :runtime
|
|
37
|
-
prerelease: false
|
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
-
requirements:
|
|
40
|
-
- - "~>"
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
version: '1.1'
|
|
43
|
-
- !ruby/object:Gem::Dependency
|
|
44
|
-
name: state_machine
|
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
|
46
|
-
requirements:
|
|
47
|
-
- - "~>"
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
49
|
-
version: '1.1'
|
|
50
|
-
type: :runtime
|
|
51
|
-
prerelease: false
|
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
-
requirements:
|
|
54
|
-
- - "~>"
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: '1.1'
|
|
14
|
+
dependencies: []
|
|
57
15
|
description: Bluepill keeps your daemons up while taking up as little resources as
|
|
58
16
|
possible. After all you probably want the resources of your server to be used by
|
|
59
17
|
whatever daemons you are running rather than the thing that's supposed to make sure
|
|
@@ -76,20 +34,39 @@ files:
|
|
|
76
34
|
- bluepill.gemspec
|
|
77
35
|
- lib/bluepill.rb
|
|
78
36
|
- lib/bluepill/application.rb
|
|
79
|
-
- lib/bluepill/
|
|
37
|
+
- lib/bluepill/application/lifecycle.rb
|
|
38
|
+
- lib/bluepill/application/listener.rb
|
|
39
|
+
- lib/bluepill/application/previous_daemon.rb
|
|
40
|
+
- lib/bluepill/base_directory.rb
|
|
80
41
|
- lib/bluepill/condition_watch.rb
|
|
81
42
|
- lib/bluepill/controller.rb
|
|
82
|
-
- lib/bluepill/
|
|
43
|
+
- lib/bluepill/controller/directory.rb
|
|
44
|
+
- lib/bluepill/daemonize.rb
|
|
83
45
|
- lib/bluepill/dsl.rb
|
|
84
46
|
- lib/bluepill/dsl/app_proxy.rb
|
|
85
47
|
- lib/bluepill/dsl/process_factory.rb
|
|
48
|
+
- lib/bluepill/dsl/process_factory/children.rb
|
|
49
|
+
- lib/bluepill/dsl/process_factory/registry.rb
|
|
86
50
|
- lib/bluepill/dsl/process_proxy.rb
|
|
87
51
|
- lib/bluepill/group.rb
|
|
88
52
|
- lib/bluepill/logger.rb
|
|
53
|
+
- lib/bluepill/pid_file.rb
|
|
89
54
|
- lib/bluepill/process.rb
|
|
55
|
+
- lib/bluepill/process/attributes.rb
|
|
56
|
+
- lib/bluepill/process/children.rb
|
|
57
|
+
- lib/bluepill/process/pid.rb
|
|
58
|
+
- lib/bluepill/process/state_machine.rb
|
|
59
|
+
- lib/bluepill/process/transition.rb
|
|
60
|
+
- lib/bluepill/process/transition_callbacks.rb
|
|
61
|
+
- lib/bluepill/process/user_commands.rb
|
|
62
|
+
- lib/bluepill/process/watches.rb
|
|
90
63
|
- lib/bluepill/process_commands.rb
|
|
64
|
+
- lib/bluepill/process_commands/execution.rb
|
|
65
|
+
- lib/bluepill/process_commands/hooks.rb
|
|
66
|
+
- lib/bluepill/process_commands/stop_signals.rb
|
|
91
67
|
- lib/bluepill/process_conditions.rb
|
|
92
68
|
- lib/bluepill/process_conditions/always_true.rb
|
|
69
|
+
- lib/bluepill/process_conditions/below_threshold.rb
|
|
93
70
|
- lib/bluepill/process_conditions/cpu_usage.rb
|
|
94
71
|
- lib/bluepill/process_conditions/file_time.rb
|
|
95
72
|
- lib/bluepill/process_conditions/http.rb
|
|
@@ -98,17 +75,30 @@ files:
|
|
|
98
75
|
- lib/bluepill/process_conditions/running_time.rb
|
|
99
76
|
- lib/bluepill/process_conditions/zombie_process.rb
|
|
100
77
|
- lib/bluepill/process_journal.rb
|
|
78
|
+
- lib/bluepill/process_journal/cleanup.rb
|
|
79
|
+
- lib/bluepill/process_journal/lock.rb
|
|
101
80
|
- lib/bluepill/process_statistics.rb
|
|
102
81
|
- lib/bluepill/socket.rb
|
|
103
82
|
- lib/bluepill/system.rb
|
|
83
|
+
- lib/bluepill/system/command_setup.rb
|
|
104
84
|
- lib/bluepill/system/commands.rb
|
|
85
|
+
- lib/bluepill/system/daemon.rb
|
|
86
|
+
- lib/bluepill/system/ps.rb
|
|
87
|
+
- lib/bluepill/system/ps_table.rb
|
|
105
88
|
- lib/bluepill/trigger.rb
|
|
106
|
-
- lib/bluepill/trigger/custom.rb
|
|
107
89
|
- lib/bluepill/triggers/flapping.rb
|
|
108
|
-
- lib/bluepill/
|
|
90
|
+
- lib/bluepill/units.rb
|
|
91
|
+
- lib/bluepill/util/inflections.rb
|
|
92
|
+
- lib/bluepill/util/levenshtein.rb
|
|
109
93
|
- lib/bluepill/util/rotational_array.rb
|
|
110
94
|
- lib/bluepill/version.rb
|
|
111
95
|
- sig/bluepill.rbs
|
|
96
|
+
- sig/bluepill/application.rbs
|
|
97
|
+
- sig/bluepill/checks.rbs
|
|
98
|
+
- sig/bluepill/dsl.rbs
|
|
99
|
+
- sig/bluepill/logger.rbs
|
|
100
|
+
- sig/bluepill/process.rbs
|
|
101
|
+
- sig/bluepill/system.rbs
|
|
112
102
|
- sig/manifest.yaml
|
|
113
103
|
homepage: https://github.com/bluepill-rb/bluepill
|
|
114
104
|
licenses:
|
|
@@ -125,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
115
|
requirements:
|
|
126
116
|
- - ">="
|
|
127
117
|
- !ruby/object:Gem::Version
|
|
128
|
-
version:
|
|
118
|
+
version: '2.0'
|
|
129
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
120
|
requirements:
|
|
131
121
|
- - ">="
|
data/lib/bluepill/clock.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module Bluepill
|
|
2
|
-
# The clock that times ticks, checks, grace times and flapping
|
|
3
|
-
#
|
|
4
|
-
# The system clock can jump, when NTP corrects it or someone sets it, so
|
|
5
|
-
# a time between two readings of Time.now can come out too long, too
|
|
6
|
-
# short or below zero. The monotonic clock only counts up, one second a
|
|
7
|
-
# second.
|
|
8
|
-
#
|
|
9
|
-
# @api private
|
|
10
|
-
module Clock
|
|
11
|
-
# Return a reader of the monotonic clock, or of the system clock
|
|
12
|
-
#
|
|
13
|
-
# Process.clock_gettime, which Ruby 2.1 added, reads the monotonic clock.
|
|
14
|
-
# Ruby 1.9.3 and 2.0, and JRuby 1.7, don't have it, so they read the
|
|
15
|
-
# system clock, as bluepill 0.1.6 did. JRuby 9.0 has no :second unit, so
|
|
16
|
-
# it reads the clock in seconds, as a Float, and drops the fraction.
|
|
17
|
-
#
|
|
18
|
-
# @param [Module] process the module with clock_gettime, if Ruby has it
|
|
19
|
-
#
|
|
20
|
-
# @return [Proc] a reader of the time, in whole seconds
|
|
21
|
-
#
|
|
22
|
-
# @api private
|
|
23
|
-
def self.reader(process = ::Process)
|
|
24
|
-
if process.respond_to?(:clock_gettime)
|
|
25
|
-
-> { Integer(process.clock_gettime(::Process::CLOCK_MONOTONIC)) }
|
|
26
|
-
else
|
|
27
|
-
-> { Integer(Time.now) }
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# The reader of this Ruby's clock, chosen once
|
|
32
|
-
#
|
|
33
|
-
# @api private
|
|
34
|
-
READER = reader
|
|
35
|
-
|
|
36
|
-
# Return the clock's time, in whole seconds
|
|
37
|
-
#
|
|
38
|
-
# The monotonic clock counts from an arbitrary point, such as when the
|
|
39
|
-
# machine booted, so a reading only means something next to another one.
|
|
40
|
-
#
|
|
41
|
-
# @return [Integer]
|
|
42
|
-
#
|
|
43
|
-
# @api private
|
|
44
|
-
def self.now
|
|
45
|
-
READER.call
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
data/lib/bluepill/deprecation.rb
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
module Bluepill
|
|
2
|
-
# Warns, once each, about what a later version of bluepill will change
|
|
3
|
-
#
|
|
4
|
-
# A warning goes to stderr, where `bluepill load` shows it, since the pill
|
|
5
|
-
# file loads before the daemon detaches, and to bluepill's log once
|
|
6
|
-
# there is one. Each key warns once per process, so a warning raised
|
|
7
|
-
# while the daemon runs doesn't fill the log.
|
|
8
|
-
#
|
|
9
|
-
# @example
|
|
10
|
-
# Bluepill::Deprecation.warn(:pre_start_command, 'bluepill 0.2.0 ...')
|
|
11
|
-
#
|
|
12
|
-
# @api private
|
|
13
|
-
module Deprecation
|
|
14
|
-
@warned = {}
|
|
15
|
-
@mutex = Mutex.new
|
|
16
|
-
@logger = nil
|
|
17
|
-
|
|
18
|
-
class << self
|
|
19
|
-
# The logger that warnings also go to, once bluepill has one
|
|
20
|
-
#
|
|
21
|
-
# The application sets it when it creates its logger.
|
|
22
|
-
#
|
|
23
|
-
# @return [Logger, nil]
|
|
24
|
-
#
|
|
25
|
-
# @api private
|
|
26
|
-
attr_accessor :logger
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Warn about a change, unless this key has warned already
|
|
30
|
-
#
|
|
31
|
-
# @param [Object] key what the warning is about, such as
|
|
32
|
-
# :pre_start_command
|
|
33
|
-
# @param [String] message what will change, in which version, and what
|
|
34
|
-
# to do now
|
|
35
|
-
#
|
|
36
|
-
# @return [Boolean] whether it warned
|
|
37
|
-
#
|
|
38
|
-
# @api private
|
|
39
|
-
def self.warn(key, message)
|
|
40
|
-
return false unless first?(key)
|
|
41
|
-
|
|
42
|
-
line = "DEPRECATION: #{message}"
|
|
43
|
-
$stderr.puts(line)
|
|
44
|
-
log = logger
|
|
45
|
-
log.warning(line) if log
|
|
46
|
-
true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Return whether a key is warning for the first time, and remember it
|
|
50
|
-
#
|
|
51
|
-
# @param [Object] key what the warning is about
|
|
52
|
-
#
|
|
53
|
-
# @return [Boolean] true the first time for each key
|
|
54
|
-
#
|
|
55
|
-
# @api private
|
|
56
|
-
def self.first?(key)
|
|
57
|
-
@mutex.synchronize do
|
|
58
|
-
return false if @warned.key?(key)
|
|
59
|
-
|
|
60
|
-
@warned[key] = true
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Forget the warnings given, and the logger, as between specs
|
|
65
|
-
#
|
|
66
|
-
# @return [void]
|
|
67
|
-
#
|
|
68
|
-
# @api private
|
|
69
|
-
def self.reset!
|
|
70
|
-
@mutex.synchronize { @warned.clear }
|
|
71
|
-
self.logger = nil
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
module Bluepill
|
|
2
|
-
class Trigger
|
|
3
|
-
# A trigger that a config defines, as a process's triggers hold it
|
|
4
|
-
#
|
|
5
|
-
# It hands the trigger each transition wrapped in a {Transition}, which
|
|
6
|
-
# warns when the trigger reads what bluepill 0.2.0's transitions don't
|
|
7
|
-
# have. Bluepill's own trigger only reads what they have, so the process
|
|
8
|
-
# holds it as it is, and its transitions cost nothing more.
|
|
9
|
-
#
|
|
10
|
-
# @api private
|
|
11
|
-
class Custom
|
|
12
|
-
# Return the trigger the config defined
|
|
13
|
-
#
|
|
14
|
-
# @return [Trigger]
|
|
15
|
-
#
|
|
16
|
-
# @api private
|
|
17
|
-
attr_reader :trigger
|
|
18
|
-
|
|
19
|
-
# Wrap a trigger that a config defined
|
|
20
|
-
#
|
|
21
|
-
# @param [Trigger] trigger the trigger
|
|
22
|
-
#
|
|
23
|
-
# @return [void]
|
|
24
|
-
#
|
|
25
|
-
# @api private
|
|
26
|
-
def initialize(trigger)
|
|
27
|
-
@trigger = trigger
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Tell the trigger about a transition, wrapped in a Transition
|
|
31
|
-
#
|
|
32
|
-
# The wrapper warns about what bluepill 0.2.0's transitions lack.
|
|
33
|
-
#
|
|
34
|
-
# @param [StateMachine::Transition] transition the transition
|
|
35
|
-
#
|
|
36
|
-
# @return [void]
|
|
37
|
-
#
|
|
38
|
-
# @api private
|
|
39
|
-
def notify(transition)
|
|
40
|
-
trigger.notify(Transition.new(transition, trigger.class))
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Cancel the trigger's scheduled events
|
|
44
|
-
#
|
|
45
|
-
# @return [void]
|
|
46
|
-
#
|
|
47
|
-
# @api private
|
|
48
|
-
def reset!
|
|
49
|
-
trigger.reset!
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Set the logger the trigger writes to
|
|
53
|
-
#
|
|
54
|
-
# @param [Logger] logger the process's logger
|
|
55
|
-
#
|
|
56
|
-
# @return [void]
|
|
57
|
-
#
|
|
58
|
-
# @api private
|
|
59
|
-
def logger=(logger)
|
|
60
|
-
trigger.logger = logger
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# A transition, as a trigger that a config defines gets it
|
|
65
|
-
#
|
|
66
|
-
# Bluepill 0.2.0 gives a trigger's notify a transition with only
|
|
67
|
-
# from_name, to_name and loopback?. This one answers everything
|
|
68
|
-
# state_machine's does, but warns about anything else a trigger calls,
|
|
69
|
-
# such as from, to or event.
|
|
70
|
-
#
|
|
71
|
-
# @api private
|
|
72
|
-
class Transition
|
|
73
|
-
# Wrap a transition
|
|
74
|
-
#
|
|
75
|
-
# @param [StateMachine::Transition] transition the transition
|
|
76
|
-
# @param [Class] trigger_class the trigger's class, which the warning
|
|
77
|
-
# names
|
|
78
|
-
#
|
|
79
|
-
# @return [void]
|
|
80
|
-
#
|
|
81
|
-
# @api private
|
|
82
|
-
def initialize(transition, trigger_class)
|
|
83
|
-
@transition = transition
|
|
84
|
-
@trigger_class = trigger_class
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Return the state the process is leaving
|
|
88
|
-
#
|
|
89
|
-
# @return [Symbol]
|
|
90
|
-
#
|
|
91
|
-
# @api private
|
|
92
|
-
def from_name
|
|
93
|
-
@transition.from_name
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Return the state the process is going to
|
|
97
|
-
#
|
|
98
|
-
# @return [Symbol]
|
|
99
|
-
#
|
|
100
|
-
# @api private
|
|
101
|
-
def to_name
|
|
102
|
-
@transition.to_name
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Return whether the process stays in the same state
|
|
106
|
-
#
|
|
107
|
-
# @return [Boolean]
|
|
108
|
-
#
|
|
109
|
-
# @api private
|
|
110
|
-
def loopback?
|
|
111
|
-
@transition.loopback?
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# Call one of the transition's other methods, with a warning
|
|
115
|
-
#
|
|
116
|
-
# @param [Symbol] name the method, such as :event
|
|
117
|
-
# @param [Array<Object>] args its arguments
|
|
118
|
-
# @param [Proc, nil] block its block
|
|
119
|
-
#
|
|
120
|
-
# @return [Object] what the transition's method returns
|
|
121
|
-
#
|
|
122
|
-
# @raise [NoMethodError] for a method the transition doesn't have
|
|
123
|
-
#
|
|
124
|
-
# @api private
|
|
125
|
-
def method_missing(name, *args, &block)
|
|
126
|
-
# The transition raises NoMethodError for a method it doesn't have
|
|
127
|
-
result = @transition.public_send(name, *args, &block)
|
|
128
|
-
message = "bluepill 0.2.0 gives a trigger's notify a transition with only from_name, to_name and loopback?, " \
|
|
129
|
-
"so #{@trigger_class}'s call of its #{name} fails there. Use from_name, to_name or loopback? instead."
|
|
130
|
-
Deprecation.warn([@trigger_class, name], message)
|
|
131
|
-
result
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
# Return whether the transition has a method
|
|
135
|
-
#
|
|
136
|
-
# @param [Symbol] name the method's name
|
|
137
|
-
# @param [Boolean] include_private whether to count private methods
|
|
138
|
-
#
|
|
139
|
-
# @return [Boolean]
|
|
140
|
-
#
|
|
141
|
-
# @api private
|
|
142
|
-
def respond_to_missing?(name, include_private)
|
|
143
|
-
@transition.respond_to?(name, include_private)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Bluepill
|
|
2
|
-
# Small helpers for the rest of bluepill
|
|
3
|
-
#
|
|
4
|
-
# @api private
|
|
5
|
-
module Util
|
|
6
|
-
# Log an error at err, with a line of its own for each backtrace line
|
|
7
|
-
#
|
|
8
|
-
# The daemon rescues what a check, a trigger or a tick raises, so the
|
|
9
|
-
# log is the only place the error shows.
|
|
10
|
-
#
|
|
11
|
-
# @example
|
|
12
|
-
# Bluepill::Util.log_error(logger, 'mem_usage check failed', error)
|
|
13
|
-
# # mem_usage check failed: RuntimeError: boom
|
|
14
|
-
# # /path/to/check.rb:12:in `run'
|
|
15
|
-
#
|
|
16
|
-
# @param [Logger] logger the logger to write to
|
|
17
|
-
# @param [String] summary what failed, which the error's class and
|
|
18
|
-
# message follow
|
|
19
|
-
# @param [Exception] error the error
|
|
20
|
-
#
|
|
21
|
-
# @return [void]
|
|
22
|
-
#
|
|
23
|
-
# @api private
|
|
24
|
-
def self.log_error(logger, summary, error)
|
|
25
|
-
logger.err("#{summary}: #{error.class}: #{error}")
|
|
26
|
-
Array(error.backtrace).each { |line| logger.err(line) }
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|