bluepill 0.1.6 → 0.2.1
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 +61 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +106 -9
- 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 +56 -254
- data/lib/bluepill/base_directory.rb +93 -0
- data/lib/bluepill/clock.rb +25 -0
- data/lib/bluepill/condition_watch.rb +136 -58
- data/lib/bluepill/controller/directory.rb +59 -0
- data/lib/bluepill/controller.rb +99 -94
- 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 -92
- data/lib/bluepill/dsl/process_proxy.rb +109 -21
- 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 +60 -657
- 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 +52 -24
- 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 -26
- 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 +33 -36
- 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 +50 -871
- metadata +40 -45
data/lib/bluepill/trigger.rb
CHANGED
|
@@ -7,6 +7,12 @@ module Bluepill
|
|
|
7
7
|
#
|
|
8
8
|
# @api private
|
|
9
9
|
class Trigger
|
|
10
|
+
# The symbol a trigger throws from notify to stop the transition it was
|
|
11
|
+
# told of. The process catches it and stays in its state.
|
|
12
|
+
#
|
|
13
|
+
# @api private
|
|
14
|
+
HALT = :halt
|
|
15
|
+
|
|
10
16
|
@implementations = {}
|
|
11
17
|
|
|
12
18
|
# Register a subclass by its underscored name, such as :flapping
|
|
@@ -18,7 +24,7 @@ module Bluepill
|
|
|
18
24
|
# @api private
|
|
19
25
|
def self.inherited(klass)
|
|
20
26
|
super
|
|
21
|
-
@implementations[klass.name.split(
|
|
27
|
+
@implementations[Util.underscore(klass.name.split("::").last).to_sym] = klass
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
# Return the trigger class a config names
|
|
@@ -47,20 +53,16 @@ module Bluepill
|
|
|
47
53
|
# @api private
|
|
48
54
|
attr_accessor :logger
|
|
49
55
|
|
|
50
|
-
# Return the lock that guards the scheduled events
|
|
51
|
-
#
|
|
52
|
-
# @return [Thread::Mutex] the lock
|
|
53
|
-
#
|
|
54
|
-
# @api private
|
|
55
|
-
attr_accessor :mutex
|
|
56
|
-
|
|
57
56
|
# Return the events the trigger scheduled, each with its thread
|
|
58
57
|
#
|
|
58
|
+
# Read them under the lock, since their threads remove them as they
|
|
59
|
+
# finish.
|
|
60
|
+
#
|
|
59
61
|
# @return [Array<Array(Symbol, Thread)>] each event and the thread that
|
|
60
62
|
# dispatches it
|
|
61
63
|
#
|
|
62
64
|
# @api private
|
|
63
|
-
|
|
65
|
+
attr_reader :scheduled_events
|
|
64
66
|
|
|
65
67
|
# Create a trigger for a process
|
|
66
68
|
#
|
|
@@ -74,8 +76,11 @@ module Bluepill
|
|
|
74
76
|
def initialize(process, options = {})
|
|
75
77
|
self.process = process
|
|
76
78
|
self.logger = options[:logger]
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
@mutex = Mutex.new
|
|
80
|
+
@scheduled_events = []
|
|
81
|
+
# The reason the trigger gives the process for what it dispatches,
|
|
82
|
+
# such as "Flapping"
|
|
83
|
+
@reason = self.class.name.split("::").last
|
|
79
84
|
end
|
|
80
85
|
|
|
81
86
|
# Cancel the events the trigger scheduled, as when the user unmonitors
|
|
@@ -97,7 +102,7 @@ module Bluepill
|
|
|
97
102
|
#
|
|
98
103
|
# @api private
|
|
99
104
|
def notify(_transition)
|
|
100
|
-
raise
|
|
105
|
+
raise "Implement in subclass"
|
|
101
106
|
end
|
|
102
107
|
|
|
103
108
|
# Send an event to the process, with the trigger's name as the reason
|
|
@@ -108,7 +113,7 @@ module Bluepill
|
|
|
108
113
|
#
|
|
109
114
|
# @api private
|
|
110
115
|
def dispatch!(event)
|
|
111
|
-
process.dispatch!(event,
|
|
116
|
+
process.dispatch!(event, @reason)
|
|
112
117
|
end
|
|
113
118
|
|
|
114
119
|
# Dispatch an event after a delay, in a thread of its own
|
|
@@ -121,34 +126,55 @@ module Bluepill
|
|
|
121
126
|
# @api private
|
|
122
127
|
def schedule_event(event, delay)
|
|
123
128
|
mutex.synchronize do
|
|
124
|
-
thread = Thread.new
|
|
125
|
-
begin
|
|
126
|
-
sleep delay.to_f
|
|
127
|
-
dispatch!(event)
|
|
128
|
-
mutex.synchronize do
|
|
129
|
-
scheduled_events.delete_if { |_, t| t.equal?(Thread.current) }
|
|
130
|
-
end
|
|
131
|
-
rescue StandardError => e
|
|
132
|
-
logger.err(e)
|
|
133
|
-
logger.err(e.backtrace.to_a.join("\n"))
|
|
134
|
-
end
|
|
135
|
-
end
|
|
129
|
+
thread = Thread.new { run_scheduled_event(event, delay) }
|
|
136
130
|
scheduled_events.push([event, thread])
|
|
137
131
|
thread
|
|
138
132
|
end
|
|
139
133
|
end
|
|
140
134
|
|
|
135
|
+
# Wait, dispatch a scheduled event, and forget it, in its own thread
|
|
136
|
+
#
|
|
137
|
+
# An error is logged, since nothing joins the thread to see it.
|
|
138
|
+
#
|
|
139
|
+
# @param [Symbol] event the event, such as :start
|
|
140
|
+
# @param [Numeric] delay the seconds to wait first
|
|
141
|
+
#
|
|
142
|
+
# @return [void]
|
|
143
|
+
#
|
|
144
|
+
# @api private
|
|
145
|
+
def run_scheduled_event(event, delay)
|
|
146
|
+
# Kernel.sleep, not sleep, so the specs can stand in for the clock.
|
|
147
|
+
# Float takes a duration, through its to_f, but not nil.
|
|
148
|
+
Kernel.sleep(Float(delay))
|
|
149
|
+
dispatch!(event)
|
|
150
|
+
mutex.synchronize do
|
|
151
|
+
scheduled_events.delete_if { |_, t| t.equal?(Thread.current) }
|
|
152
|
+
end
|
|
153
|
+
rescue => e
|
|
154
|
+
logger.err(e)
|
|
155
|
+
logger.err(e.backtrace.to_a.join("\n"))
|
|
156
|
+
end
|
|
157
|
+
|
|
141
158
|
# Cancel every scheduled event, killing its thread
|
|
142
159
|
#
|
|
143
160
|
# @return [void]
|
|
144
161
|
#
|
|
145
162
|
# @api private
|
|
146
163
|
def cancel_all_events
|
|
147
|
-
logger.info
|
|
164
|
+
logger.info "Canceling all scheduled events"
|
|
148
165
|
mutex.synchronize do
|
|
149
166
|
scheduled_events.collect(&:last).each(&:kill)
|
|
150
167
|
scheduled_events.clear
|
|
151
168
|
end
|
|
152
169
|
end
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
|
|
173
|
+
# Return the lock that guards the scheduled events
|
|
174
|
+
#
|
|
175
|
+
# @return [Thread::Mutex] the lock
|
|
176
|
+
#
|
|
177
|
+
# @api private
|
|
178
|
+
attr_reader :mutex
|
|
153
179
|
end
|
|
154
180
|
end
|
|
@@ -20,12 +20,7 @@ module Bluepill
|
|
|
20
20
|
# The states that a start or a restart moves the process to
|
|
21
21
|
#
|
|
22
22
|
# @api private
|
|
23
|
-
TRIGGER_STATES = [
|
|
24
|
-
|
|
25
|
-
# The options the trigger takes
|
|
26
|
-
#
|
|
27
|
-
# @api private
|
|
28
|
-
PARAMS = [:times, :within, :retry_in].freeze
|
|
23
|
+
TRIGGER_STATES = %i[starting restarting].freeze
|
|
29
24
|
|
|
30
25
|
# Return how many starts or restarts count as flapping
|
|
31
26
|
#
|
|
@@ -65,12 +60,9 @@ module Bluepill
|
|
|
65
60
|
#
|
|
66
61
|
# @api private
|
|
67
62
|
def initialize(process, options = {})
|
|
68
|
-
options.
|
|
69
|
-
|
|
70
|
-
options.
|
|
71
|
-
instance_variable_set("@#{name}", val) if PARAMS.include?(name)
|
|
72
|
-
end
|
|
73
|
-
|
|
63
|
+
@times = options.fetch(:times, 5)
|
|
64
|
+
@within = options.fetch(:within, 1)
|
|
65
|
+
@retry_in = options.fetch(:retry_in, 5)
|
|
74
66
|
@timeline = Util::RotationalArray.new(@times)
|
|
75
67
|
super
|
|
76
68
|
end
|
|
@@ -86,7 +78,7 @@ module Bluepill
|
|
|
86
78
|
def notify(transition)
|
|
87
79
|
return unless TRIGGER_STATES.include?(transition.to_name)
|
|
88
80
|
|
|
89
|
-
timeline <<
|
|
81
|
+
timeline << Clock.now
|
|
90
82
|
check_flapping
|
|
91
83
|
end
|
|
92
84
|
|
|
@@ -107,7 +99,7 @@ module Bluepill
|
|
|
107
99
|
#
|
|
108
100
|
# @return [void]
|
|
109
101
|
#
|
|
110
|
-
# @raise [UncaughtThrowError]
|
|
102
|
+
# @raise [UncaughtThrowError] HALT, which the process catches to stop
|
|
111
103
|
# the transition that flapped
|
|
112
104
|
#
|
|
113
105
|
# @api private
|
|
@@ -125,8 +117,8 @@ module Bluepill
|
|
|
125
117
|
|
|
126
118
|
@timeline.clear
|
|
127
119
|
|
|
128
|
-
#
|
|
129
|
-
throw
|
|
120
|
+
# Keep the process from making the transition that flapped
|
|
121
|
+
throw HALT
|
|
130
122
|
end
|
|
131
123
|
end
|
|
132
124
|
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
module Bluepill
|
|
2
|
+
# The durations and sizes a config writes, such as 10.seconds and
|
|
3
|
+
# 100.megabytes, as plain numbers of seconds and bytes
|
|
4
|
+
#
|
|
5
|
+
# Bluepill includes this module in Numeric, so a method that Numeric
|
|
6
|
+
# already has comes first. A config that loads ActiveSupport, say by
|
|
7
|
+
# loading a Rails app, gets ActiveSupport's versions, which bluepill
|
|
8
|
+
# accepts too.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# process.start_grace_time = 10.seconds # => 10
|
|
12
|
+
# process.checks :mem_usage, below: 100.megabytes # => 104_857_600
|
|
13
|
+
#
|
|
14
|
+
# @api public
|
|
15
|
+
module Units
|
|
16
|
+
# The number of seconds in a minute
|
|
17
|
+
MINUTE = 60
|
|
18
|
+
# The number of seconds in an hour
|
|
19
|
+
HOUR = 60 * MINUTE
|
|
20
|
+
# The number of seconds in a day
|
|
21
|
+
DAY = 24 * HOUR
|
|
22
|
+
# The number of bytes in a kilobyte
|
|
23
|
+
KILOBYTE = 1024
|
|
24
|
+
# The number of bytes in a megabyte
|
|
25
|
+
MEGABYTE = 1024 * KILOBYTE
|
|
26
|
+
# The number of bytes in a gigabyte
|
|
27
|
+
GIGABYTE = 1024 * MEGABYTE
|
|
28
|
+
|
|
29
|
+
# Return this many seconds, in seconds
|
|
30
|
+
#
|
|
31
|
+
# @example
|
|
32
|
+
# 10.seconds # => 10
|
|
33
|
+
#
|
|
34
|
+
# @return [Numeric] the number itself
|
|
35
|
+
#
|
|
36
|
+
# @api public
|
|
37
|
+
def seconds
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
alias_method :second, :seconds
|
|
41
|
+
|
|
42
|
+
# Return this many minutes, in seconds
|
|
43
|
+
#
|
|
44
|
+
# @example
|
|
45
|
+
# 2.minutes # => 120
|
|
46
|
+
#
|
|
47
|
+
# @return [Numeric] the number of seconds
|
|
48
|
+
#
|
|
49
|
+
# @api public
|
|
50
|
+
def minutes
|
|
51
|
+
self * MINUTE
|
|
52
|
+
end
|
|
53
|
+
alias_method :minute, :minutes
|
|
54
|
+
|
|
55
|
+
# Return this many hours, in seconds
|
|
56
|
+
#
|
|
57
|
+
# @example
|
|
58
|
+
# 1.hour # => 3600
|
|
59
|
+
#
|
|
60
|
+
# @return [Numeric] the number of seconds
|
|
61
|
+
#
|
|
62
|
+
# @api public
|
|
63
|
+
def hours
|
|
64
|
+
self * HOUR
|
|
65
|
+
end
|
|
66
|
+
alias_method :hour, :hours
|
|
67
|
+
|
|
68
|
+
# Return this many days, in seconds
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# 1.day # => 86400
|
|
72
|
+
#
|
|
73
|
+
# @return [Numeric] the number of seconds
|
|
74
|
+
#
|
|
75
|
+
# @api public
|
|
76
|
+
def days
|
|
77
|
+
self * DAY
|
|
78
|
+
end
|
|
79
|
+
alias_method :day, :days
|
|
80
|
+
|
|
81
|
+
# Return this many kilobytes, in bytes
|
|
82
|
+
#
|
|
83
|
+
# @example
|
|
84
|
+
# 600.kilobytes # => 614400
|
|
85
|
+
#
|
|
86
|
+
# @return [Numeric] the number of bytes
|
|
87
|
+
#
|
|
88
|
+
# @api public
|
|
89
|
+
def kilobytes
|
|
90
|
+
self * KILOBYTE
|
|
91
|
+
end
|
|
92
|
+
alias_method :kilobyte, :kilobytes
|
|
93
|
+
|
|
94
|
+
# Return this many megabytes, in bytes
|
|
95
|
+
#
|
|
96
|
+
# @example
|
|
97
|
+
# 100.megabytes # => 104857600
|
|
98
|
+
#
|
|
99
|
+
# @return [Numeric] the number of bytes
|
|
100
|
+
#
|
|
101
|
+
# @api public
|
|
102
|
+
def megabytes
|
|
103
|
+
self * MEGABYTE
|
|
104
|
+
end
|
|
105
|
+
alias_method :megabyte, :megabytes
|
|
106
|
+
|
|
107
|
+
# Return this many gigabytes, in bytes
|
|
108
|
+
#
|
|
109
|
+
# @example
|
|
110
|
+
# 1.gigabyte # => 1073741824
|
|
111
|
+
#
|
|
112
|
+
# @return [Numeric] the number of bytes
|
|
113
|
+
#
|
|
114
|
+
# @api public
|
|
115
|
+
def gigabytes
|
|
116
|
+
self * GIGABYTE
|
|
117
|
+
end
|
|
118
|
+
alias_method :gigabyte, :gigabytes
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Numeric's own methods, such as ActiveSupport's, come before an included
|
|
123
|
+
# module's, so these never replace them
|
|
124
|
+
class Numeric
|
|
125
|
+
include Bluepill::Units
|
|
126
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Bluepill
|
|
2
|
+
# Small helpers bluepill keeps for itself
|
|
3
|
+
#
|
|
4
|
+
# @api private
|
|
5
|
+
module Util
|
|
6
|
+
# Turn a snake_case name into CamelCase, as ActiveSupport's camelize does
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# Bluepill::Util.camelize(:mem_usage) # => "MemUsage"
|
|
10
|
+
#
|
|
11
|
+
# @param [#to_s] name a name such as :mem_usage
|
|
12
|
+
#
|
|
13
|
+
# @return [String] the name in CamelCase, such as "MemUsage"
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
def self.camelize(name)
|
|
17
|
+
name.to_s.sub(/\A[a-z]/, &:upcase).gsub(/_[a-z\d]*/i) { |part| part.delete("_").capitalize }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Turn a CamelCase name into snake_case, as ActiveSupport's underscore does
|
|
21
|
+
#
|
|
22
|
+
# @example
|
|
23
|
+
# Bluepill::Util.underscore("HTTPCheck") # => "http_check"
|
|
24
|
+
#
|
|
25
|
+
# @param [String] name a name such as "Flapping"
|
|
26
|
+
#
|
|
27
|
+
# @return [String] the name in snake_case, such as "flapping"
|
|
28
|
+
#
|
|
29
|
+
# @api private
|
|
30
|
+
def self.underscore(name)
|
|
31
|
+
name.gsub(/([A-Z\d])([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Bluepill
|
|
2
|
+
module Util
|
|
3
|
+
# Return how many edits turn one string into another
|
|
4
|
+
#
|
|
5
|
+
# Counts the characters to insert, delete or replace (the Levenshtein
|
|
6
|
+
# distance), a row of the table at a time. ProcessProxy uses it to
|
|
7
|
+
# suggest the attribute closest to a misspelled one.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Bluepill::Util.levenshtein_distance("start_comand", "start_command") # => 1
|
|
11
|
+
#
|
|
12
|
+
# @param [String] from the string to start from
|
|
13
|
+
# @param [String] to the string to end at
|
|
14
|
+
#
|
|
15
|
+
# @return [Integer] the number of edits
|
|
16
|
+
#
|
|
17
|
+
# @api private
|
|
18
|
+
def self.levenshtein_distance(from, to)
|
|
19
|
+
row = (0..to.length).to_a
|
|
20
|
+
from.each_char.with_index(1) do |from_char, i|
|
|
21
|
+
next_levenshtein_row!(row, i, from_char, to)
|
|
22
|
+
end
|
|
23
|
+
row.fetch(-1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Turn a row of the distance table into the next one, in place
|
|
27
|
+
#
|
|
28
|
+
# Cell j becomes the fewest edits that turn the first from_length
|
|
29
|
+
# characters of the from string into the first j characters of the to
|
|
30
|
+
# string.
|
|
31
|
+
#
|
|
32
|
+
# @param [Array<Integer>] row the row for the characters before from_char
|
|
33
|
+
# @param [Integer] from_length the number of from's characters, through
|
|
34
|
+
# from_char
|
|
35
|
+
# @param [String] from_char the from string's next character
|
|
36
|
+
# @param [String] to the string to end at
|
|
37
|
+
#
|
|
38
|
+
# @return [void]
|
|
39
|
+
#
|
|
40
|
+
# @api private
|
|
41
|
+
def self.next_levenshtein_row!(row, from_length, from_char, to)
|
|
42
|
+
diagonal = row.fetch(0)
|
|
43
|
+
row[0] = from_length
|
|
44
|
+
to.each_char.with_index(1) do |to_char, j|
|
|
45
|
+
above = row.fetch(j)
|
|
46
|
+
substitution = diagonal + (from_char.eql?(to_char) ? 0 : 1)
|
|
47
|
+
row[j] = [above + 1, row.fetch(j - 1) + 1, substitution].min
|
|
48
|
+
diagonal = above
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
private_class_method :next_levenshtein_row!
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/bluepill/version.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Bluepill
|
|
|
2
2
|
# The version of bluepill
|
|
3
3
|
#
|
|
4
4
|
# @example
|
|
5
|
-
# Bluepill::Version.to_s # => "0.1
|
|
5
|
+
# Bluepill::Version.to_s # => "0.2.1"
|
|
6
6
|
#
|
|
7
7
|
# @api public
|
|
8
8
|
module Version
|
|
@@ -21,25 +21,25 @@ module Bluepill
|
|
|
21
21
|
# Return the minor version
|
|
22
22
|
#
|
|
23
23
|
# @example
|
|
24
|
-
# Bluepill::Version.minor # =>
|
|
24
|
+
# Bluepill::Version.minor # => 2
|
|
25
25
|
#
|
|
26
26
|
# @return [Integer] the minor version
|
|
27
27
|
#
|
|
28
28
|
# @api public
|
|
29
29
|
def self.minor
|
|
30
|
-
|
|
30
|
+
2
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Return the patch version
|
|
34
34
|
#
|
|
35
35
|
# @example
|
|
36
|
-
# Bluepill::Version.patch # =>
|
|
36
|
+
# Bluepill::Version.patch # => 1
|
|
37
37
|
#
|
|
38
38
|
# @return [Integer] the patch version
|
|
39
39
|
#
|
|
40
40
|
# @api public
|
|
41
41
|
def self.patch
|
|
42
|
-
|
|
42
|
+
1
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Return the pre-release version
|
|
@@ -50,12 +50,13 @@ module Bluepill
|
|
|
50
50
|
# @return [Integer, nil] the pre-release version, or nil for a release
|
|
51
51
|
#
|
|
52
52
|
# @api public
|
|
53
|
-
def self.pre
|
|
53
|
+
def self.pre
|
|
54
|
+
end
|
|
54
55
|
|
|
55
56
|
# Return the version's parts by name
|
|
56
57
|
#
|
|
57
58
|
# @example
|
|
58
|
-
# Bluepill::Version.to_h # => {major: 0, minor:
|
|
59
|
+
# Bluepill::Version.to_h # => {major: 0, minor: 2, patch: 1, pre: nil}
|
|
59
60
|
#
|
|
60
61
|
# @return [Hash{Symbol => Integer, nil}] the major, minor, patch and
|
|
61
62
|
# pre-release versions
|
|
@@ -66,14 +67,14 @@ module Bluepill
|
|
|
66
67
|
major: major,
|
|
67
68
|
minor: minor,
|
|
68
69
|
patch: patch,
|
|
69
|
-
pre: pre
|
|
70
|
+
pre: pre
|
|
70
71
|
}
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
# Return the version's parts, without a missing pre-release version
|
|
74
75
|
#
|
|
75
76
|
# @example
|
|
76
|
-
# Bluepill::Version.to_a # => [0,
|
|
77
|
+
# Bluepill::Version.to_a # => [0, 2, 1]
|
|
77
78
|
#
|
|
78
79
|
# @return [Array<Integer>] the parts of the version
|
|
79
80
|
#
|
|
@@ -85,13 +86,13 @@ module Bluepill
|
|
|
85
86
|
# Return the version as a string
|
|
86
87
|
#
|
|
87
88
|
# @example
|
|
88
|
-
# Bluepill::Version.to_s # => "0.1
|
|
89
|
+
# Bluepill::Version.to_s # => "0.2.1"
|
|
89
90
|
#
|
|
90
|
-
# @return [String] the version, such as "0.1
|
|
91
|
+
# @return [String] the version, such as "0.2.1"
|
|
91
92
|
#
|
|
92
93
|
# @api public
|
|
93
94
|
def self.to_s
|
|
94
|
-
to_a.join(
|
|
95
|
+
to_a.join(".")
|
|
95
96
|
end
|
|
96
97
|
end
|
|
97
98
|
end
|
data/lib/bluepill.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "rubygems"
|
|
2
2
|
|
|
3
3
|
# A process monitor that keeps daemons running
|
|
4
4
|
#
|
|
@@ -19,43 +19,40 @@ module Bluepill
|
|
|
19
19
|
# when there's no Gemfile
|
|
20
20
|
#
|
|
21
21
|
# @api private
|
|
22
|
-
def self.setup_bundler(gemfile = ENV
|
|
23
|
-
require
|
|
22
|
+
def self.setup_bundler(gemfile = ENV.fetch("BUNDLE_GEMFILE", nil))
|
|
23
|
+
require "bundler/setup" if gemfile && File.exist?(gemfile)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
Bluepill.setup_bundler
|
|
28
28
|
|
|
29
|
-
require
|
|
30
|
-
require
|
|
31
|
-
require
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
require
|
|
35
|
-
require
|
|
36
|
-
|
|
37
|
-
require
|
|
38
|
-
require
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
require
|
|
42
|
-
require
|
|
43
|
-
|
|
44
|
-
require
|
|
45
|
-
require
|
|
46
|
-
require
|
|
47
|
-
require
|
|
48
|
-
require
|
|
49
|
-
require
|
|
50
|
-
require
|
|
51
|
-
require
|
|
52
|
-
require
|
|
53
|
-
|
|
54
|
-
require
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
require 'bluepill/util/rotational_array'
|
|
60
|
-
|
|
61
|
-
require 'bluepill/version'
|
|
29
|
+
require "monitor"
|
|
30
|
+
require "timeout"
|
|
31
|
+
require "logger"
|
|
32
|
+
|
|
33
|
+
require "bluepill/clock"
|
|
34
|
+
require "bluepill/units"
|
|
35
|
+
require "bluepill/util/inflections"
|
|
36
|
+
|
|
37
|
+
require "bluepill/dsl/process_proxy"
|
|
38
|
+
require "bluepill/dsl/process_factory"
|
|
39
|
+
require "bluepill/dsl/app_proxy"
|
|
40
|
+
|
|
41
|
+
require "bluepill/application"
|
|
42
|
+
require "bluepill/controller"
|
|
43
|
+
require "bluepill/socket"
|
|
44
|
+
require "bluepill/process"
|
|
45
|
+
require "bluepill/process_statistics"
|
|
46
|
+
require "bluepill/group"
|
|
47
|
+
require "bluepill/logger"
|
|
48
|
+
require "bluepill/condition_watch"
|
|
49
|
+
require "bluepill/trigger"
|
|
50
|
+
require "bluepill/triggers/flapping"
|
|
51
|
+
require "bluepill/dsl"
|
|
52
|
+
require "bluepill/system"
|
|
53
|
+
|
|
54
|
+
require "bluepill/process_conditions"
|
|
55
|
+
|
|
56
|
+
require "bluepill/util/rotational_array"
|
|
57
|
+
|
|
58
|
+
require "bluepill/version"
|