bluepill 0.2.0 → 0.2.3
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 +23 -1
- data/README.md +2 -2
- data/bin/bluepill +1 -0
- data/bluepill.gemspec +3 -1
- data/lib/bluepill/application/lifecycle.rb +3 -1
- data/lib/bluepill/application/listener.rb +4 -2
- data/lib/bluepill/application/previous_daemon.rb +2 -0
- data/lib/bluepill/application.rb +2 -1
- data/lib/bluepill/base_directory.rb +2 -0
- data/lib/bluepill/clock.rb +27 -0
- data/lib/bluepill/condition_watch.rb +5 -3
- data/lib/bluepill/controller/directory.rb +2 -0
- data/lib/bluepill/controller.rb +2 -0
- data/lib/bluepill/daemonize.rb +2 -0
- data/lib/bluepill/dsl/app_proxy.rb +2 -0
- data/lib/bluepill/dsl/process_factory/children.rb +2 -0
- data/lib/bluepill/dsl/process_factory/registry.rb +2 -0
- data/lib/bluepill/dsl/process_factory.rb +2 -0
- data/lib/bluepill/dsl/process_proxy.rb +2 -0
- data/lib/bluepill/dsl.rb +2 -0
- data/lib/bluepill/group.rb +2 -0
- data/lib/bluepill/logger.rb +3 -1
- data/lib/bluepill/pid_file.rb +2 -0
- data/lib/bluepill/process/attributes.rb +2 -0
- data/lib/bluepill/process/children.rb +2 -0
- data/lib/bluepill/process/pid.rb +2 -0
- data/lib/bluepill/process/state_machine.rb +3 -1
- data/lib/bluepill/process/transition.rb +2 -0
- data/lib/bluepill/process/transition_callbacks.rb +2 -0
- data/lib/bluepill/process/user_commands.rb +2 -0
- data/lib/bluepill/process/watches.rb +3 -1
- data/lib/bluepill/process.rb +7 -5
- data/lib/bluepill/process_commands/execution.rb +3 -1
- data/lib/bluepill/process_commands/hooks.rb +2 -0
- data/lib/bluepill/process_commands/stop_signals.rb +2 -0
- data/lib/bluepill/process_commands.rb +6 -4
- data/lib/bluepill/process_conditions/always_true.rb +2 -0
- data/lib/bluepill/process_conditions/below_threshold.rb +2 -0
- data/lib/bluepill/process_conditions/cpu_usage.rb +2 -0
- data/lib/bluepill/process_conditions/file_time.rb +2 -0
- data/lib/bluepill/process_conditions/http.rb +2 -0
- data/lib/bluepill/process_conditions/mem_usage.rb +5 -3
- data/lib/bluepill/process_conditions/process_condition.rb +2 -0
- data/lib/bluepill/process_conditions/running_time.rb +2 -0
- data/lib/bluepill/process_conditions/zombie_process.rb +2 -0
- data/lib/bluepill/process_conditions.rb +2 -0
- data/lib/bluepill/process_journal/cleanup.rb +3 -1
- data/lib/bluepill/process_journal/lock.rb +2 -0
- data/lib/bluepill/process_journal.rb +5 -3
- data/lib/bluepill/process_statistics.rb +3 -1
- data/lib/bluepill/socket.rb +2 -0
- data/lib/bluepill/system/command_setup.rb +3 -1
- data/lib/bluepill/system/commands.rb +2 -0
- data/lib/bluepill/system/daemon.rb +2 -0
- data/lib/bluepill/system/ps.rb +2 -0
- data/lib/bluepill/system/ps_table.rb +2 -0
- data/lib/bluepill/system.rb +4 -2
- data/lib/bluepill/trigger.rb +2 -0
- data/lib/bluepill/triggers/flapping.rb +3 -1
- data/lib/bluepill/units.rb +2 -0
- data/lib/bluepill/util/inflections.rb +2 -0
- data/lib/bluepill/util/levenshtein.rb +2 -0
- data/lib/bluepill/util/rotational_array.rb +2 -0
- data/lib/bluepill/version.rb +9 -7
- data/lib/bluepill.rb +3 -1
- data/sig/bluepill.rbs +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c8d27b19dbe30a5a18761f09310196ec0217443587cb6da651bd371b1532566f
|
|
4
|
+
data.tar.gz: 4bc4799e210e6da938c82ebbb3a26330b2438a391c4adffae574986103ebf08a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cebf575f741efdf1e50b9c190382d146c986a1bfb74bee2b9f4d0ab0335c13cdbf8f1123a6e2d9451dd470db15c9806beb089cf06f4580497e3c4ac8fc45450
|
|
7
|
+
data.tar.gz: 0cd636224f8688383a44e6f7f8f7e321836186e4a52e2ebef88d1f6179d687018373709c643070b352d4bdf6edf0bb95fbb221017aa071726e400c3d53a00b21
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.3] - 2026-11-02
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bluepill's string literals are frozen, so parsing `ps` each tick makes 10% fewer objects and takes 3% fewer instructions, and checks and `bluepill status` make a few fewer.
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
- **Breaking:** support for Ruby 2.1 and 2.2, and for JRuby 9.0, which runs Ruby 2.2 code. Bluepill 0.2.3 needs Ruby 2.3 or newer, or JRuby 9.1 or newer. Bluepill 0.2.1 still runs on them.
|
|
19
|
+
|
|
20
|
+
## [0.2.1] - 2026-11-02
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- **Breaking:** support for Ruby 2.0. Bluepill 0.2.1 needs Ruby 2.1 or newer, or JRuby 9.0 or newer. Bluepill 0.2.0 still runs on Ruby 2.0.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Bluepill timed its ticks, checks, grace times and flapping detection with the system clock, so a change to the clock, such as an NTP correction after a VM resumes, could put off ticks and checks for as long as the clock went back, or end grace times early when it went forward. It now times them with the monotonic clock, which only counts up, and a tick no longer makes a `Time` to do it.
|
|
29
|
+
|
|
10
30
|
## [0.2.0] - 2026-11-02
|
|
11
31
|
|
|
12
32
|
### Upgrading from 0.1
|
|
@@ -812,7 +832,9 @@ Initial release.
|
|
|
812
832
|
- Added the `bluepill` CLI with the `load`, `status`, `start`, `stop`, `restart`, `unmonitor`, `quit` and `log` commands.
|
|
813
833
|
- Added syslog logging.
|
|
814
834
|
|
|
815
|
-
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.
|
|
835
|
+
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.3...HEAD
|
|
836
|
+
[0.2.3]: https://github.com/bluepill-rb/bluepill/compare/v0.2.1...v0.2.3
|
|
837
|
+
[0.2.1]: https://github.com/bluepill-rb/bluepill/compare/v0.2.0...v0.2.1
|
|
816
838
|
[0.2.0]: https://github.com/bluepill-rb/bluepill/compare/v0.1.6...v0.2.0
|
|
817
839
|
[0.1.6]: https://github.com/bluepill-rb/bluepill/compare/v0.1.5...v0.1.6
|
|
818
840
|
[0.1.5]: https://github.com/bluepill-rb/bluepill/compare/v0.1.4...v0.1.5
|
data/README.md
CHANGED
|
@@ -504,10 +504,10 @@ JRuby allows you to run bluepill only in the foreground.
|
|
|
504
504
|
This library aims to support and is [tested against][ci] the following Ruby
|
|
505
505
|
implementations:
|
|
506
506
|
|
|
507
|
-
* Ruby 2.
|
|
507
|
+
* Ruby 2.3 through 2.7
|
|
508
508
|
* Ruby 3.0 through 3.4
|
|
509
509
|
* Ruby 4.0
|
|
510
|
-
* JRuby 9.
|
|
510
|
+
* JRuby 9.1 through 9.4 (only in the foreground)
|
|
511
511
|
* JRuby 10.0 and 10.1 (only in the foreground)
|
|
512
512
|
|
|
513
513
|
If something doesn't work on one of these interpreters, please open an issue.
|
data/bin/bluepill
CHANGED
data/bluepill.gemspec
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
lib = File.expand_path("lib", __dir__)
|
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
5
|
require "bluepill/version"
|
|
@@ -20,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
20
22
|
"rubygems_mfa_required" => "true"
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
spec.required_ruby_version = ">= 2.
|
|
25
|
+
spec.required_ruby_version = ">= 2.3"
|
|
24
26
|
|
|
25
27
|
# sig has the RBS signatures, and the standard libraries they use in manifest.yaml
|
|
26
28
|
spec.executables = %w[bluepill bpsv]
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
class Application
|
|
3
5
|
# Start the daemon, run it until a signal stops it, and clean up after
|
|
@@ -117,7 +119,7 @@ module Bluepill
|
|
|
117
119
|
Signal.trap("INT", &terminator)
|
|
118
120
|
|
|
119
121
|
Signal.trap("HUP") do
|
|
120
|
-
logger
|
|
122
|
+
logger&.reopen
|
|
121
123
|
end
|
|
122
124
|
end
|
|
123
125
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
class Application
|
|
3
5
|
# Answer the commands that the CLI sends over the daemon's socket
|
|
@@ -19,7 +21,7 @@ module Bluepill
|
|
|
19
21
|
# @api private
|
|
20
22
|
def start_listener
|
|
21
23
|
previous_thread = @listener_thread
|
|
22
|
-
previous_thread
|
|
24
|
+
previous_thread&.kill
|
|
23
25
|
@listener_thread = Thread.new do
|
|
24
26
|
loop do
|
|
25
27
|
answer_next_client
|
|
@@ -115,7 +117,7 @@ module Bluepill
|
|
|
115
117
|
#
|
|
116
118
|
# @api private
|
|
117
119
|
def close_client(client)
|
|
118
|
-
client
|
|
120
|
+
client&.close
|
|
119
121
|
rescue IOError
|
|
120
122
|
# closed stream
|
|
121
123
|
end
|
data/lib/bluepill/application.rb
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bluepill
|
|
4
|
+
# The clock that times ticks, checks and grace times
|
|
5
|
+
#
|
|
6
|
+
# The system clock can jump, when NTP corrects it or someone sets it, so
|
|
7
|
+
# a time between two readings of Time.now can come out too long, too
|
|
8
|
+
# short or below zero. The monotonic clock only counts up, one second a
|
|
9
|
+
# second.
|
|
10
|
+
#
|
|
11
|
+
# @api private
|
|
12
|
+
module Clock
|
|
13
|
+
# Return the monotonic clock's time, in whole seconds
|
|
14
|
+
#
|
|
15
|
+
# It counts from an arbitrary point, such as when the machine booted, so
|
|
16
|
+
# a reading only means something next to another one. JRuby 9.0 has no
|
|
17
|
+
# :second unit, so it reads the clock in seconds, as a Float, and drops
|
|
18
|
+
# the fraction.
|
|
19
|
+
#
|
|
20
|
+
# @return [Integer]
|
|
21
|
+
#
|
|
22
|
+
# @api private
|
|
23
|
+
def self.now
|
|
24
|
+
Integer(::Process.clock_gettime(::Process::CLOCK_MONOTONIC))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
# Runs a process's check every so often, and fires its events when the
|
|
3
5
|
# check fails often enough
|
|
@@ -121,7 +123,7 @@ module Bluepill
|
|
|
121
123
|
#
|
|
122
124
|
# It's due on its first run, and then every `every` seconds.
|
|
123
125
|
#
|
|
124
|
-
# @param [Integer] tick_number the
|
|
126
|
+
# @param [Integer] tick_number the time, from Clock.now
|
|
125
127
|
#
|
|
126
128
|
# @return [Boolean]
|
|
127
129
|
#
|
|
@@ -137,7 +139,7 @@ module Bluepill
|
|
|
137
139
|
# run adds the value to the history and logs the history.
|
|
138
140
|
#
|
|
139
141
|
# @param [Integer, nil] pid the process's pid
|
|
140
|
-
# @param [Integer] tick_number the
|
|
142
|
+
# @param [Integer] tick_number the time, from Clock.now
|
|
141
143
|
#
|
|
142
144
|
# @return [Array<Symbol>] the events to fire, empty unless the check
|
|
143
145
|
# ran and failed often enough
|
|
@@ -146,7 +148,7 @@ module Bluepill
|
|
|
146
148
|
# System::PsError, after logging it
|
|
147
149
|
#
|
|
148
150
|
# @api private
|
|
149
|
-
def run(pid, tick_number =
|
|
151
|
+
def run(pid, tick_number = Clock.now)
|
|
150
152
|
# The same test as due?, written out to save a call on every check.
|
|
151
153
|
# An if, not a guard clause: the guard ran 3% slower on the zombie
|
|
152
154
|
# benchmark, with the same instructions.
|
data/lib/bluepill/controller.rb
CHANGED
data/lib/bluepill/daemonize.rb
CHANGED
data/lib/bluepill/dsl.rb
CHANGED
data/lib/bluepill/group.rb
CHANGED
data/lib/bluepill/logger.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
# Write bluepill's log, to syslog or a file, with prefixes
|
|
3
5
|
#
|
|
@@ -87,7 +89,7 @@ module Bluepill
|
|
|
87
89
|
# @return [void]
|
|
88
90
|
# @api private
|
|
89
91
|
LOG_METHODS.each_with_index do |method, priority|
|
|
90
|
-
class_eval
|
|
92
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
91
93
|
def #{method}(msg, prefix = nil) # def emerg(msg, prefix = nil)
|
|
92
94
|
# Below the log level, so dropped before anything is formatted
|
|
93
95
|
return if #{priority} > @level # return if 0 > @level
|
data/lib/bluepill/pid_file.rb
CHANGED
data/lib/bluepill/process/pid.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
class Process
|
|
3
5
|
# Moves a Process between its states
|
|
@@ -39,7 +41,7 @@ module Bluepill
|
|
|
39
41
|
|
|
40
42
|
# The transition from each state to itself, made once, so a tick that
|
|
41
43
|
# leaves the state alone makes no new object
|
|
42
|
-
LOOPBACKS =
|
|
44
|
+
LOOPBACKS = STATES.collect { |state| [state, Transition.new(state, state).freeze] }.to_h.freeze
|
|
43
45
|
|
|
44
46
|
# Return the process's state, such as :up
|
|
45
47
|
#
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
class Process
|
|
3
5
|
# The checks that run on a Process every interval, such as its memory
|
|
@@ -94,7 +96,7 @@ module Bluepill
|
|
|
94
96
|
# the others. One that isn't due would do nothing, so it gets no
|
|
95
97
|
# thread.
|
|
96
98
|
#
|
|
97
|
-
# @param [Integer] now the time,
|
|
99
|
+
# @param [Integer] now the time, from Clock.now
|
|
98
100
|
#
|
|
99
101
|
# @yieldreturn [Integer, nil] the process's pid, read on each watch's
|
|
100
102
|
# thread
|
data/lib/bluepill/process.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bluepill/system"
|
|
2
4
|
require "bluepill/process_journal"
|
|
3
5
|
require "bluepill/process_commands"
|
|
@@ -48,7 +50,7 @@ module Bluepill
|
|
|
48
50
|
# @api private
|
|
49
51
|
attr_accessor :triggers
|
|
50
52
|
|
|
51
|
-
# Return the time,
|
|
53
|
+
# Return the time, from Clock.now, before which ticks are skipped
|
|
52
54
|
#
|
|
53
55
|
# Set while a start, stop or restart command has its grace time to take
|
|
54
56
|
# effect.
|
|
@@ -242,7 +244,7 @@ module Bluepill
|
|
|
242
244
|
#
|
|
243
245
|
# @api private
|
|
244
246
|
def run_watches
|
|
245
|
-
events = watches.run(
|
|
247
|
+
events = watches.run(Clock.now) { actual_pid }
|
|
246
248
|
return if events.empty?
|
|
247
249
|
|
|
248
250
|
@transitioned = false
|
|
@@ -280,11 +282,11 @@ module Bluepill
|
|
|
280
282
|
#
|
|
281
283
|
# @param [Integer, Float] seconds how long to skip ticks for
|
|
282
284
|
#
|
|
283
|
-
# @return [Integer] when ticks resume,
|
|
285
|
+
# @return [Integer] when ticks resume, from Clock.now
|
|
284
286
|
#
|
|
285
287
|
# @api private
|
|
286
288
|
def skip_ticks_for(seconds)
|
|
287
|
-
self.skip_ticks_until = (skip_ticks_until ||
|
|
289
|
+
self.skip_ticks_until = (skip_ticks_until || Clock.now) + Integer(seconds)
|
|
288
290
|
end
|
|
289
291
|
|
|
290
292
|
# Return whether ticks are being skipped
|
|
@@ -293,7 +295,7 @@ module Bluepill
|
|
|
293
295
|
#
|
|
294
296
|
# @api private
|
|
295
297
|
def skipping_ticks?
|
|
296
|
-
skip_ticks_until && skip_ticks_until >
|
|
298
|
+
skip_ticks_until && skip_ticks_until > Clock.now
|
|
297
299
|
end
|
|
298
300
|
end
|
|
299
301
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
module ProcessCommands
|
|
3
5
|
# Runs a Process's commands as its user, in its working_dir, with its
|
|
@@ -79,7 +81,7 @@ module Bluepill
|
|
|
79
81
|
result = System.execute_blocking(cmd, options)
|
|
80
82
|
# The exit code is nil when a signal killed the command
|
|
81
83
|
exit_code = result.fetch(:exit_code)
|
|
82
|
-
return if exit_code
|
|
84
|
+
return if exit_code&.zero?
|
|
83
85
|
|
|
84
86
|
logger.warning "#{description} command execution returned non-zero exit code:"
|
|
85
87
|
logger.warning result.inspect
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bluepill/process_commands/execution"
|
|
2
4
|
require "bluepill/process_commands/hooks"
|
|
3
5
|
require "bluepill/process_commands/stop_signals"
|
|
@@ -19,7 +21,7 @@ module Bluepill
|
|
|
19
21
|
# and then on_start_timeout is dispatched. Ticks are skipped for
|
|
20
22
|
# start_grace_time either way.
|
|
21
23
|
#
|
|
22
|
-
# @return [Integer] when ticks resume,
|
|
24
|
+
# @return [Integer] when ticks resume, from Clock.now
|
|
23
25
|
#
|
|
24
26
|
# @api private
|
|
25
27
|
def start_process
|
|
@@ -82,7 +84,7 @@ module Bluepill
|
|
|
82
84
|
# Stop signals are sent from a thread of their own, with their delays.
|
|
83
85
|
# Ticks are skipped for stop_grace_time.
|
|
84
86
|
#
|
|
85
|
-
# @return [Integer] when ticks resume,
|
|
87
|
+
# @return [Integer] when ticks resume, from Clock.now
|
|
86
88
|
#
|
|
87
89
|
# @api private
|
|
88
90
|
def stop_process
|
|
@@ -141,7 +143,7 @@ module Bluepill
|
|
|
141
143
|
|
|
142
144
|
# Restart the process with its restart command, or by stopping and starting
|
|
143
145
|
#
|
|
144
|
-
# @return [Integer] when ticks resume,
|
|
146
|
+
# @return [Integer] when ticks resume, from Clock.now
|
|
145
147
|
#
|
|
146
148
|
# @api private
|
|
147
149
|
def restart_process
|
|
@@ -161,7 +163,7 @@ module Bluepill
|
|
|
161
163
|
#
|
|
162
164
|
# @param [String] command the restart command
|
|
163
165
|
#
|
|
164
|
-
# @return [Integer] when ticks resume,
|
|
166
|
+
# @return [Integer] when ticks resume, from Clock.now
|
|
165
167
|
#
|
|
166
168
|
# @api private
|
|
167
169
|
def run_restart_command(command)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
module ProcessConditions
|
|
3
5
|
# Checks a process's memory usage (its resident set size)
|
|
@@ -19,17 +21,17 @@ module Bluepill
|
|
|
19
21
|
# How a value shows in the history: a number and its unit
|
|
20
22
|
#
|
|
21
23
|
# @api private
|
|
22
|
-
FORMAT_STR = "%d%s"
|
|
24
|
+
FORMAT_STR = "%d%s"
|
|
23
25
|
|
|
24
26
|
# The unit of a value that shows in megabytes
|
|
25
27
|
#
|
|
26
28
|
# @api private
|
|
27
|
-
MB_LABEL = "MB"
|
|
29
|
+
MB_LABEL = "MB"
|
|
28
30
|
|
|
29
31
|
# The unit of a value that shows in kilobytes
|
|
30
32
|
#
|
|
31
33
|
# @api private
|
|
32
|
-
KB_LABEL = "KB"
|
|
34
|
+
KB_LABEL = "KB"
|
|
33
35
|
|
|
34
36
|
# Read the process's memory usage from the tick's ps table
|
|
35
37
|
#
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
module ProcessJournal
|
|
3
5
|
# Kill what an earlier run left in a process's journals
|
|
@@ -138,7 +140,7 @@ module Bluepill
|
|
|
138
140
|
# Journals only grow until they're cleared, under the lock this runs in
|
|
139
141
|
return [] unless File.exist?(filename)
|
|
140
142
|
|
|
141
|
-
started =
|
|
143
|
+
started = journal_entries(filename).to_h
|
|
142
144
|
boot = System.boot_time
|
|
143
145
|
written = Integer(File.mtime(filename))
|
|
144
146
|
ids.select do |id|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bluepill/system"
|
|
2
4
|
require "bluepill/process_journal/cleanup"
|
|
3
5
|
require "bluepill/process_journal/lock"
|
|
@@ -66,12 +68,12 @@ module Bluepill
|
|
|
66
68
|
# A pid journal's kind
|
|
67
69
|
#
|
|
68
70
|
# @api private
|
|
69
|
-
PID = Kind.new("pid"
|
|
71
|
+
PID = Kind.new("pid", "process", "pids", 1).freeze
|
|
70
72
|
|
|
71
73
|
# A process group journal's kind
|
|
72
74
|
#
|
|
73
75
|
# @api private
|
|
74
|
-
PGID = Kind.new("pgid"
|
|
76
|
+
PGID = Kind.new("pgid", "process group", "pgids", -1).freeze
|
|
75
77
|
|
|
76
78
|
class << self
|
|
77
79
|
# Return the logger the journal writes to
|
|
@@ -216,7 +218,7 @@ module Bluepill
|
|
|
216
218
|
def self.journal_entries(filename)
|
|
217
219
|
File.readlines(filename).collect do |line|
|
|
218
220
|
id, started = line.split
|
|
219
|
-
[id.to_i, started
|
|
221
|
+
[id.to_i, started&.to_i]
|
|
220
222
|
end
|
|
221
223
|
end
|
|
222
224
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
# Keeps a process's last few events, which bluepill status shows
|
|
3
5
|
#
|
|
4
6
|
# @api private
|
|
5
7
|
class ProcessStatistics
|
|
6
8
|
# How status shows each event's time
|
|
7
|
-
STRFTIME = "%m/%d/%Y %H:%M:%S"
|
|
9
|
+
STRFTIME = "%m/%d/%Y %H:%M:%S"
|
|
8
10
|
|
|
9
11
|
# How many events are kept
|
|
10
12
|
EVENTS_TO_PERSIST = 10
|
data/lib/bluepill/socket.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "etc"
|
|
2
4
|
|
|
3
5
|
module Bluepill
|
|
@@ -22,7 +24,7 @@ module Bluepill
|
|
|
22
24
|
working_dir = options[:working_dir]
|
|
23
25
|
Dir.chdir(ENV["PWD"] = working_dir.to_s) if working_dir
|
|
24
26
|
environment = options[:environment]
|
|
25
|
-
environment
|
|
27
|
+
environment&.each { |key, value| ENV[key.to_s] = value.to_s }
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
# Switch to another user and groups, when bluepill runs as root
|
data/lib/bluepill/system/ps.rb
CHANGED
data/lib/bluepill/system.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bluepill/system/ps"
|
|
2
4
|
require "bluepill/system/commands"
|
|
3
5
|
|
|
@@ -19,7 +21,7 @@ module Bluepill
|
|
|
19
21
|
# The mode that a daemon's stdout and stderr files are opened in
|
|
20
22
|
#
|
|
21
23
|
# @api private
|
|
22
|
-
APPEND_MODE = "a"
|
|
24
|
+
APPEND_MODE = "a"
|
|
23
25
|
|
|
24
26
|
# Raised when ps could not be run, so there is no data for this tick
|
|
25
27
|
#
|
|
@@ -152,7 +154,7 @@ module Bluepill
|
|
|
152
154
|
# @api private
|
|
153
155
|
def self.command(pid)
|
|
154
156
|
row = ps_axu.row(pid)
|
|
155
|
-
row
|
|
157
|
+
row&.fetch(PsTable::COMMAND)
|
|
156
158
|
end
|
|
157
159
|
|
|
158
160
|
# Delete a file if it exists
|
data/lib/bluepill/trigger.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
# The triggers a process can have
|
|
3
5
|
#
|
|
@@ -78,7 +80,7 @@ module Bluepill
|
|
|
78
80
|
def notify(transition)
|
|
79
81
|
return unless TRIGGER_STATES.include?(transition.to_name)
|
|
80
82
|
|
|
81
|
-
timeline <<
|
|
83
|
+
timeline << Clock.now
|
|
82
84
|
check_flapping
|
|
83
85
|
end
|
|
84
86
|
|
data/lib/bluepill/units.rb
CHANGED
data/lib/bluepill/version.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Bluepill
|
|
2
4
|
# The version of bluepill
|
|
3
5
|
#
|
|
4
6
|
# @example
|
|
5
|
-
# Bluepill::Version.to_s # => "0.2.
|
|
7
|
+
# Bluepill::Version.to_s # => "0.2.3"
|
|
6
8
|
#
|
|
7
9
|
# @api public
|
|
8
10
|
module Version
|
|
@@ -33,13 +35,13 @@ module Bluepill
|
|
|
33
35
|
# Return the patch version
|
|
34
36
|
#
|
|
35
37
|
# @example
|
|
36
|
-
# Bluepill::Version.patch # =>
|
|
38
|
+
# Bluepill::Version.patch # => 3
|
|
37
39
|
#
|
|
38
40
|
# @return [Integer] the patch version
|
|
39
41
|
#
|
|
40
42
|
# @api public
|
|
41
43
|
def self.patch
|
|
42
|
-
|
|
44
|
+
3
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
# Return the pre-release version
|
|
@@ -56,7 +58,7 @@ module Bluepill
|
|
|
56
58
|
# Return the version's parts by name
|
|
57
59
|
#
|
|
58
60
|
# @example
|
|
59
|
-
# Bluepill::Version.to_h # => {major: 0, minor: 2, patch:
|
|
61
|
+
# Bluepill::Version.to_h # => {major: 0, minor: 2, patch: 3, pre: nil}
|
|
60
62
|
#
|
|
61
63
|
# @return [Hash{Symbol => Integer, nil}] the major, minor, patch and
|
|
62
64
|
# pre-release versions
|
|
@@ -74,7 +76,7 @@ module Bluepill
|
|
|
74
76
|
# Return the version's parts, without a missing pre-release version
|
|
75
77
|
#
|
|
76
78
|
# @example
|
|
77
|
-
# Bluepill::Version.to_a # => [0, 2,
|
|
79
|
+
# Bluepill::Version.to_a # => [0, 2, 3]
|
|
78
80
|
#
|
|
79
81
|
# @return [Array<Integer>] the parts of the version
|
|
80
82
|
#
|
|
@@ -86,9 +88,9 @@ module Bluepill
|
|
|
86
88
|
# Return the version as a string
|
|
87
89
|
#
|
|
88
90
|
# @example
|
|
89
|
-
# Bluepill::Version.to_s # => "0.2.
|
|
91
|
+
# Bluepill::Version.to_s # => "0.2.3"
|
|
90
92
|
#
|
|
91
|
-
# @return [String] the version, such as "0.2.
|
|
93
|
+
# @return [String] the version, such as "0.2.3"
|
|
92
94
|
#
|
|
93
95
|
# @api public
|
|
94
96
|
def self.to_s
|
data/lib/bluepill.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "rubygems"
|
|
2
4
|
|
|
3
5
|
# A process monitor that keeps daemons running
|
|
@@ -26,11 +28,11 @@ end
|
|
|
26
28
|
|
|
27
29
|
Bluepill.setup_bundler
|
|
28
30
|
|
|
29
|
-
require "thread"
|
|
30
31
|
require "monitor"
|
|
31
32
|
require "timeout"
|
|
32
33
|
require "logger"
|
|
33
34
|
|
|
35
|
+
require "bluepill/clock"
|
|
34
36
|
require "bluepill/units"
|
|
35
37
|
require "bluepill/util/inflections"
|
|
36
38
|
|
data/sig/bluepill.rbs
CHANGED
|
@@ -33,6 +33,11 @@ module Bluepill
|
|
|
33
33
|
def self.to_s: () -> String
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# The monotonic clock that times ticks, checks and grace times
|
|
37
|
+
module Clock
|
|
38
|
+
def self.now: () -> Integer
|
|
39
|
+
end
|
|
40
|
+
|
|
36
41
|
# What a process passes to its transition callbacks and triggers
|
|
37
42
|
interface _Transition
|
|
38
43
|
def from_name: () -> Symbol?
|
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.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arya Asemanfar
|
|
@@ -38,6 +38,7 @@ files:
|
|
|
38
38
|
- lib/bluepill/application/listener.rb
|
|
39
39
|
- lib/bluepill/application/previous_daemon.rb
|
|
40
40
|
- lib/bluepill/base_directory.rb
|
|
41
|
+
- lib/bluepill/clock.rb
|
|
41
42
|
- lib/bluepill/condition_watch.rb
|
|
42
43
|
- lib/bluepill/controller.rb
|
|
43
44
|
- lib/bluepill/controller/directory.rb
|
|
@@ -115,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
115
116
|
requirements:
|
|
116
117
|
- - ">="
|
|
117
118
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: '2.
|
|
119
|
+
version: '2.3'
|
|
119
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
requirements:
|
|
121
122
|
- - ">="
|