bluepill 0.2.1 → 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 +12 -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 -0
- data/lib/bluepill/base_directory.rb +2 -0
- data/lib/bluepill/clock.rb +2 -0
- data/lib/bluepill/condition_watch.rb +2 -0
- 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 +2 -0
- 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 +2 -0
- data/lib/bluepill/process.rb +2 -0
- 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 +2 -0
- 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 +2 -0
- 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 +2 -0
- 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 +2 -0
- metadata +2 -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,16 @@ 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
|
+
|
|
10
20
|
## [0.2.1] - 2026-11-02
|
|
11
21
|
|
|
12
22
|
### Removed
|
|
@@ -822,7 +832,8 @@ Initial release.
|
|
|
822
832
|
- Added the `bluepill` CLI with the `load`, `status`, `start`, `stop`, `restart`, `unmonitor`, `quit` and `log` commands.
|
|
823
833
|
- Added syslog logging.
|
|
824
834
|
|
|
825
|
-
[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
|
|
826
837
|
[0.2.1]: https://github.com/bluepill-rb/bluepill/compare/v0.2.0...v0.2.1
|
|
827
838
|
[0.2.0]: https://github.com/bluepill-rb/bluepill/compare/v0.1.6...v0.2.0
|
|
828
839
|
[0.1.6]: https://github.com/bluepill-rb/bluepill/compare/v0.1.5...v0.1.6
|
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
data/lib/bluepill/clock.rb
CHANGED
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
data/lib/bluepill/process.rb
CHANGED
|
@@ -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
|
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
|
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
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
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
|
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
116
116
|
requirements:
|
|
117
117
|
- - ">="
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: '2.
|
|
119
|
+
version: '2.3'
|
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - ">="
|