bluepill 0.2.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 479806cb2fec4bce8b5dda9efcc35f2fd155aa3520d25916b3fa8ce3ee8b9670
4
- data.tar.gz: 4a7681b538732c743423ca2f8921c097950bddd313b56f92c97ecff9e7b4435a
3
+ metadata.gz: 24bda9b03c07276b7cd052d90f53e89cc2499b6317dead57a64b7a95a2fe9a82
4
+ data.tar.gz: 39de75c1d40bf17038c37dbb5149feb4d41902c57b372d915720505504217924
5
5
  SHA512:
6
- metadata.gz: e1fc693888a977f958df3f854d9a19c38ee87ad36832329afdd58489d268d9749e57c74af7566138ef8edb4f3b29618d261757c87ae15fca4039baa6191ab30f
7
- data.tar.gz: b186296ac77abe6a1c8fdc5f2bdfba9d4e598f576b77956283be641150df041c7b939075c9c78615445c23f8b90848f1b1d747668b8ac5563eb48ae630f2238d
6
+ metadata.gz: 2d177dd6ee49fde6b7eb69b98a01302c53950ef7564bbb2aeac680b671a272dc0b32abd7f3a341b779a5ce0bfc09ce57e6ba304cc5c4d46714cfb06cd20c7af4
7
+ data.tar.gz: e607adb3667ee40d5b29343363d39e86b6c8d43835f0b48c58c7dad4c15465073dab130e5bab5fced3b266a05ac5de9065c9f8fe2d6fd23294396328757f4e38
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.1] - 2026-11-02
11
+
12
+ ### Removed
13
+
14
+ - **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.
15
+
16
+ ### Fixed
17
+
18
+ - 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.
19
+
10
20
  ## [0.2.0] - 2026-11-02
11
21
 
12
22
  ### Upgrading from 0.1
@@ -812,7 +822,8 @@ Initial release.
812
822
  - Added the `bluepill` CLI with the `load`, `status`, `start`, `stop`, `restart`, `unmonitor`, `quit` and `log` commands.
813
823
  - Added syslog logging.
814
824
 
815
- [unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.0...HEAD
825
+ [unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.2.1...HEAD
826
+ [0.2.1]: https://github.com/bluepill-rb/bluepill/compare/v0.2.0...v0.2.1
816
827
  [0.2.0]: https://github.com/bluepill-rb/bluepill/compare/v0.1.6...v0.2.0
817
828
  [0.1.6]: https://github.com/bluepill-rb/bluepill/compare/v0.1.5...v0.1.6
818
829
  [0.1.5]: https://github.com/bluepill-rb/bluepill/compare/v0.1.4...v0.1.5
data/README.md CHANGED
@@ -504,7 +504,7 @@ 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.0 through 2.7
507
+ * Ruby 2.1 through 2.7
508
508
  * Ruby 3.0 through 3.4
509
509
  * Ruby 4.0
510
510
  * JRuby 9.0 through 9.4 (only in the foreground)
data/bluepill.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  "rubygems_mfa_required" => "true"
21
21
  }
22
22
 
23
- spec.required_ruby_version = ">= 2.0"
23
+ spec.required_ruby_version = ">= 2.1"
24
24
 
25
25
  # sig has the RBS signatures, and the standard libraries they use in manifest.yaml
26
26
  spec.executables = %w[bluepill bpsv]
@@ -1,4 +1,3 @@
1
- require "thread"
2
1
  require "bluepill/system"
3
2
  require "bluepill/process_journal"
4
3
  require "bluepill/base_directory"
@@ -0,0 +1,25 @@
1
+ module Bluepill
2
+ # The clock that times ticks, checks and grace times
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 the monotonic clock's time, in whole seconds
12
+ #
13
+ # It counts from an arbitrary point, such as when the machine booted, so
14
+ # a reading only means something next to another one. JRuby 9.0 has no
15
+ # :second unit, so it reads the clock in seconds, as a Float, and drops
16
+ # the fraction.
17
+ #
18
+ # @return [Integer]
19
+ #
20
+ # @api private
21
+ def self.now
22
+ Integer(::Process.clock_gettime(::Process::CLOCK_MONOTONIC))
23
+ end
24
+ end
25
+ end
@@ -121,7 +121,7 @@ module Bluepill
121
121
  #
122
122
  # It's due on its first run, and then every `every` seconds.
123
123
  #
124
- # @param [Integer] tick_number the current time, in seconds
124
+ # @param [Integer] tick_number the time, from Clock.now
125
125
  #
126
126
  # @return [Boolean]
127
127
  #
@@ -137,7 +137,7 @@ module Bluepill
137
137
  # run adds the value to the history and logs the history.
138
138
  #
139
139
  # @param [Integer, nil] pid the process's pid
140
- # @param [Integer] tick_number the current time, in seconds
140
+ # @param [Integer] tick_number the time, from Clock.now
141
141
  #
142
142
  # @return [Array<Symbol>] the events to fire, empty unless the check
143
143
  # ran and failed often enough
@@ -146,7 +146,7 @@ module Bluepill
146
146
  # System::PsError, after logging it
147
147
  #
148
148
  # @api private
149
- def run(pid, tick_number = Integer(Time.now))
149
+ def run(pid, tick_number = Clock.now)
150
150
  # The same test as due?, written out to save a call on every check.
151
151
  # An if, not a guard clause: the guard ran 3% slower on the zombie
152
152
  # benchmark, with the same instructions.
@@ -39,7 +39,7 @@ module Bluepill
39
39
 
40
40
  # The transition from each state to itself, made once, so a tick that
41
41
  # leaves the state alone makes no new object
42
- LOOPBACKS = Hash[STATES.zip(STATES.collect { |state| Transition.new(state, state).freeze })].freeze
42
+ LOOPBACKS = STATES.collect { |state| [state, Transition.new(state, state).freeze] }.to_h.freeze
43
43
 
44
44
  # Return the process's state, such as :up
45
45
  #
@@ -94,7 +94,7 @@ module Bluepill
94
94
  # the others. One that isn't due would do nothing, so it gets no
95
95
  # thread.
96
96
  #
97
- # @param [Integer] now the time, in epoch seconds
97
+ # @param [Integer] now the time, from Clock.now
98
98
  #
99
99
  # @yieldreturn [Integer, nil] the process's pid, read on each watch's
100
100
  # thread
@@ -48,7 +48,7 @@ module Bluepill
48
48
  # @api private
49
49
  attr_accessor :triggers
50
50
 
51
- # Return the time, in epoch seconds, before which ticks are skipped
51
+ # Return the time, from Clock.now, before which ticks are skipped
52
52
  #
53
53
  # Set while a start, stop or restart command has its grace time to take
54
54
  # effect.
@@ -242,7 +242,7 @@ module Bluepill
242
242
  #
243
243
  # @api private
244
244
  def run_watches
245
- events = watches.run(Integer(Time.now)) { actual_pid }
245
+ events = watches.run(Clock.now) { actual_pid }
246
246
  return if events.empty?
247
247
 
248
248
  @transitioned = false
@@ -280,11 +280,11 @@ module Bluepill
280
280
  #
281
281
  # @param [Integer, Float] seconds how long to skip ticks for
282
282
  #
283
- # @return [Integer] when ticks resume, in epoch seconds
283
+ # @return [Integer] when ticks resume, from Clock.now
284
284
  #
285
285
  # @api private
286
286
  def skip_ticks_for(seconds)
287
- self.skip_ticks_until = (skip_ticks_until || Integer(Time.now)) + Integer(seconds)
287
+ self.skip_ticks_until = (skip_ticks_until || Clock.now) + Integer(seconds)
288
288
  end
289
289
 
290
290
  # Return whether ticks are being skipped
@@ -293,7 +293,7 @@ module Bluepill
293
293
  #
294
294
  # @api private
295
295
  def skipping_ticks?
296
- skip_ticks_until && skip_ticks_until > Integer(Time.now)
296
+ skip_ticks_until && skip_ticks_until > Clock.now
297
297
  end
298
298
  end
299
299
  end
@@ -19,7 +19,7 @@ module Bluepill
19
19
  # and then on_start_timeout is dispatched. Ticks are skipped for
20
20
  # start_grace_time either way.
21
21
  #
22
- # @return [Integer] when ticks resume, in epoch seconds
22
+ # @return [Integer] when ticks resume, from Clock.now
23
23
  #
24
24
  # @api private
25
25
  def start_process
@@ -82,7 +82,7 @@ module Bluepill
82
82
  # Stop signals are sent from a thread of their own, with their delays.
83
83
  # Ticks are skipped for stop_grace_time.
84
84
  #
85
- # @return [Integer] when ticks resume, in epoch seconds
85
+ # @return [Integer] when ticks resume, from Clock.now
86
86
  #
87
87
  # @api private
88
88
  def stop_process
@@ -141,7 +141,7 @@ module Bluepill
141
141
 
142
142
  # Restart the process with its restart command, or by stopping and starting
143
143
  #
144
- # @return [Integer] when ticks resume, in epoch seconds
144
+ # @return [Integer] when ticks resume, from Clock.now
145
145
  #
146
146
  # @api private
147
147
  def restart_process
@@ -161,7 +161,7 @@ module Bluepill
161
161
  #
162
162
  # @param [String] command the restart command
163
163
  #
164
- # @return [Integer] when ticks resume, in epoch seconds
164
+ # @return [Integer] when ticks resume, from Clock.now
165
165
  #
166
166
  # @api private
167
167
  def run_restart_command(command)
@@ -138,7 +138,7 @@ module Bluepill
138
138
  # Journals only grow until they're cleared, under the lock this runs in
139
139
  return [] unless File.exist?(filename)
140
140
 
141
- started = Hash[journal_entries(filename)]
141
+ started = journal_entries(filename).to_h
142
142
  boot = System.boot_time
143
143
  written = Integer(File.mtime(filename))
144
144
  ids.select do |id|
@@ -78,7 +78,7 @@ module Bluepill
78
78
  def notify(transition)
79
79
  return unless TRIGGER_STATES.include?(transition.to_name)
80
80
 
81
- timeline << Integer(Time.now)
81
+ timeline << Clock.now
82
82
  check_flapping
83
83
  end
84
84
 
@@ -2,7 +2,7 @@ module Bluepill
2
2
  # The version of bluepill
3
3
  #
4
4
  # @example
5
- # Bluepill::Version.to_s # => "0.2.0"
5
+ # Bluepill::Version.to_s # => "0.2.1"
6
6
  #
7
7
  # @api public
8
8
  module Version
@@ -33,13 +33,13 @@ module Bluepill
33
33
  # Return the patch version
34
34
  #
35
35
  # @example
36
- # Bluepill::Version.patch # => 0
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
- 0
42
+ 1
43
43
  end
44
44
 
45
45
  # Return the pre-release version
@@ -56,7 +56,7 @@ module Bluepill
56
56
  # Return the version's parts by name
57
57
  #
58
58
  # @example
59
- # Bluepill::Version.to_h # => {major: 0, minor: 2, patch: 0, pre: nil}
59
+ # Bluepill::Version.to_h # => {major: 0, minor: 2, patch: 1, pre: nil}
60
60
  #
61
61
  # @return [Hash{Symbol => Integer, nil}] the major, minor, patch and
62
62
  # pre-release versions
@@ -74,7 +74,7 @@ module Bluepill
74
74
  # Return the version's parts, without a missing pre-release version
75
75
  #
76
76
  # @example
77
- # Bluepill::Version.to_a # => [0, 2, 0]
77
+ # Bluepill::Version.to_a # => [0, 2, 1]
78
78
  #
79
79
  # @return [Array<Integer>] the parts of the version
80
80
  #
@@ -86,9 +86,9 @@ module Bluepill
86
86
  # Return the version as a string
87
87
  #
88
88
  # @example
89
- # Bluepill::Version.to_s # => "0.2.0"
89
+ # Bluepill::Version.to_s # => "0.2.1"
90
90
  #
91
- # @return [String] the version, such as "0.2.0"
91
+ # @return [String] the version, such as "0.2.1"
92
92
  #
93
93
  # @api public
94
94
  def self.to_s
data/lib/bluepill.rb CHANGED
@@ -26,11 +26,11 @@ end
26
26
 
27
27
  Bluepill.setup_bundler
28
28
 
29
- require "thread"
30
29
  require "monitor"
31
30
  require "timeout"
32
31
  require "logger"
33
32
 
33
+ require "bluepill/clock"
34
34
  require "bluepill/units"
35
35
  require "bluepill/util/inflections"
36
36
 
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.0
4
+ version: 0.2.1
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.0'
119
+ version: '2.1'
119
120
  required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
122
  - - ">="