bluepill 0.2.1 → 0.2.5
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 +2 -2
- 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 +8 -10
- 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 +3 -1
- 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 +6 -6
- 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 +6 -2
- 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 +3 -1
- data/lib/bluepill/process_conditions.rb +2 -0
- data/lib/bluepill/process_journal/cleanup.rb +6 -6
- 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 +6 -6
- 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: 5288f18359d2a2384f55d6b9d245b37182bda58cf9588301d02738caaaad631c
|
|
4
|
+
data.tar.gz: 1447ebe71f6ebe9be37ab4edd2ac3b695582b96995c2e3bb00ad1f20ec3a0361
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a837a60160c8aebb1dffc7d5206d30e79f9f84f2c4e65d6c879de0a94f9ffe7bb961c6aa0b0bdd7443fcdff60bb5ca8204a733058becf3fa5e2e320b70b458ad
|
|
7
|
+
data.tar.gz: 81fcacb8b9618c91dce85f862312e90c2a3bdd227500e795310d8d7646e001224bd27d37a36abb06a1b27ac4a4d77cca8ec5148d6b4ff12c09f2e53275d9ea37
|
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.5] - 2026-11-02
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The `zombie_process` check tests for `<defunct>` with `match?`, so each check makes one fewer object.
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
- **Breaking:** support for Ruby 2.3 and 2.4, and for JRuby 9.1, which runs Ruby 2.3 code. Bluepill 0.2.5 needs Ruby 2.5 or newer, or JRuby 9.2 or newer. Bluepill 0.2.3 still runs on them.
|
|
19
|
+
|
|
20
|
+
## [0.2.3] - 2026-11-02
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- 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.
|
|
25
|
+
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
- **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.
|
|
29
|
+
|
|
10
30
|
## [0.2.1] - 2026-11-02
|
|
11
31
|
|
|
12
32
|
### Removed
|
|
@@ -822,7 +842,9 @@ Initial release.
|
|
|
822
842
|
- Added the `bluepill` CLI with the `load`, `status`, `start`, `stop`, `restart`, `unmonitor`, `quit` and `log` commands.
|
|
823
843
|
- Added syslog logging.
|
|
824
844
|
|
|
825
|
-
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.
|
|
845
|
+
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.5...HEAD
|
|
846
|
+
[0.2.5]: https://github.com/bluepill-rb/bluepill/compare/v0.2.3...v0.2.5
|
|
847
|
+
[0.2.3]: https://github.com/bluepill-rb/bluepill/compare/v0.2.1...v0.2.3
|
|
826
848
|
[0.2.1]: https://github.com/bluepill-rb/bluepill/compare/v0.2.0...v0.2.1
|
|
827
849
|
[0.2.0]: https://github.com/bluepill-rb/bluepill/compare/v0.1.6...v0.2.0
|
|
828
850
|
[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.5 through 2.7
|
|
508
508
|
* Ruby 3.0 through 3.4
|
|
509
509
|
* Ruby 4.0
|
|
510
|
-
* JRuby 9.
|
|
510
|
+
* JRuby 9.2 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require "optparse"
|
|
3
4
|
require "rbconfig"
|
|
4
5
|
require "bluepill"
|
|
@@ -68,8 +69,7 @@ end
|
|
|
68
69
|
|
|
69
70
|
APPLICATION_COMMANDS = %w[status start stop restart unmonitor quit log].freeze
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
controller = Bluepill::Controller.new(options.select { |key, _| %i[base_dir log_file].include?(key) })
|
|
72
|
+
controller = Bluepill::Controller.new(options.slice(:base_dir, :log_file))
|
|
73
73
|
|
|
74
74
|
if controller.running_applications.include?(File.basename($PROGRAM_NAME)) && File.symlink?($PROGRAM_NAME)
|
|
75
75
|
# bluepill was called as a symlink with the name of the target application
|
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.5"
|
|
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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# The parts of the daemons gem that bluepill uses, which bluepill used to
|
|
2
4
|
# get from blue-daemons, a fork of it. They're adapted from daemons'
|
|
3
5
|
# lib/daemons/daemonize.rb, which carries this notice:
|
|
@@ -50,11 +52,9 @@ module Bluepill
|
|
|
50
52
|
# @api private
|
|
51
53
|
def self.safefork
|
|
52
54
|
loop do
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
sleep 5
|
|
57
|
-
end
|
|
55
|
+
return fork
|
|
56
|
+
rescue Errno::EWOULDBLOCK
|
|
57
|
+
sleep 5
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -199,11 +199,9 @@ module Bluepill
|
|
|
199
199
|
# @api private
|
|
200
200
|
def self.close_fds
|
|
201
201
|
(3..MAX_FD).each do |fd|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
nil
|
|
206
|
-
end
|
|
202
|
+
IO.for_fd(fd).close
|
|
203
|
+
rescue
|
|
204
|
+
nil
|
|
207
205
|
end
|
|
208
206
|
end
|
|
209
207
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bluepill/dsl/process_factory/children"
|
|
2
4
|
require "bluepill/dsl/process_factory/registry"
|
|
3
5
|
|
|
@@ -188,7 +190,7 @@ module Bluepill
|
|
|
188
190
|
# @api private
|
|
189
191
|
def validate_stop_grace_time!(stop_signals, stop_grace_time)
|
|
190
192
|
delays = stop_signals.select.with_index { |_, i| i.odd? }
|
|
191
|
-
return unless stop_grace_time.nil? || stop_grace_time <= delays.
|
|
193
|
+
return unless stop_grace_time.nil? || stop_grace_time <= delays.sum
|
|
192
194
|
|
|
193
195
|
config_error!("Config Error: Stop_grace_time should be greater than the sum of stop_signals delays!")
|
|
194
196
|
end
|
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
|
# Runs what a Process does on its way from one state to another
|
|
@@ -62,12 +64,10 @@ module Bluepill
|
|
|
62
64
|
# @api private
|
|
63
65
|
def notify_triggers(transition)
|
|
64
66
|
triggers.each do |trigger|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
raise
|
|
70
|
-
end
|
|
67
|
+
trigger.notify(transition)
|
|
68
|
+
rescue => e
|
|
69
|
+
logger.err e.backtrace
|
|
70
|
+
raise
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
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
|
require "net/http"
|
|
2
4
|
require "uri"
|
|
3
5
|
|
|
@@ -69,10 +71,12 @@ module Bluepill
|
|
|
69
71
|
# @api private
|
|
70
72
|
def check?(value)
|
|
71
73
|
return false unless value.is_a?(@kind)
|
|
72
|
-
|
|
74
|
+
|
|
75
|
+
pattern = @pattern
|
|
76
|
+
return true unless pattern
|
|
73
77
|
|
|
74
78
|
response = value #: Net::HTTPResponse
|
|
75
|
-
|
|
79
|
+
pattern.match?(response.body)
|
|
76
80
|
end
|
|
77
81
|
|
|
78
82
|
private
|
|
@@ -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 ProcessConditions
|
|
3
5
|
# Checks whether a process is a zombie, which ps shows as <defunct>
|
|
@@ -32,7 +34,7 @@ module Bluepill
|
|
|
32
34
|
#
|
|
33
35
|
# @api private
|
|
34
36
|
def check?(value)
|
|
35
|
-
(
|
|
37
|
+
!value&.match?(/<defunct>/)
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
end
|
|
@@ -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
|
|
@@ -187,12 +189,10 @@ module Bluepill
|
|
|
187
189
|
def signal_journaled(signal, ids, kind)
|
|
188
190
|
past, verb = signal.eql?("TERM") ? %w[Termed term] : %w[Killed kill]
|
|
189
191
|
ids.each do |id|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
logger.debug("Unable to #{verb} missing #{kind.label} #{id}")
|
|
195
|
-
end
|
|
192
|
+
::Process.kill(signal, kind.sign * id)
|
|
193
|
+
logger.info("#{past} old #{kind.label} #{id}")
|
|
194
|
+
rescue Errno::ESRCH
|
|
195
|
+
logger.debug("Unable to #{verb} missing #{kind.label} #{id}")
|
|
196
196
|
end
|
|
197
197
|
end
|
|
198
198
|
end
|
|
@@ -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 "socket"
|
|
2
4
|
require "bluepill/base_directory"
|
|
3
5
|
|
|
@@ -44,12 +46,10 @@ module Bluepill
|
|
|
44
46
|
def self.client_command(base_dir, name, command)
|
|
45
47
|
res = nil
|
|
46
48
|
MAX_ATTEMPTS.times do |current_attempt|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
retry_or_abort(current_attempt)
|
|
52
|
-
end
|
|
49
|
+
res = send_command(base_dir, name, command)
|
|
50
|
+
break
|
|
51
|
+
rescue EOFError, Timeout::Error
|
|
52
|
+
retry_or_abort(current_attempt)
|
|
53
53
|
end
|
|
54
54
|
res
|
|
55
55
|
end
|
|
@@ -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.5"
|
|
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 # => 5
|
|
37
39
|
#
|
|
38
40
|
# @return [Integer] the patch version
|
|
39
41
|
#
|
|
40
42
|
# @api public
|
|
41
43
|
def self.patch
|
|
42
|
-
|
|
44
|
+
5
|
|
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: 5, 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, 5]
|
|
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.5"
|
|
90
92
|
#
|
|
91
|
-
# @return [String] the version, such as "0.2.
|
|
93
|
+
# @return [String] the version, such as "0.2.5"
|
|
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.5
|
|
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.5'
|
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - ">="
|