bluepill 0.1.5 → 0.1.6
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 +8 -1
- data/lib/bluepill/application.rb +27 -2
- data/lib/bluepill/version.rb +7 -7
- data/sig/bluepill.rbs +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fc2c246694d286bd189536ffd4e3abd220d04fde87872246a81179d6fd23b6f
|
|
4
|
+
data.tar.gz: 9ca9c2325d09134b23b8c6f7f1b3265805bdd5f56f8476ca75425ef4e0d92094
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18a4f5d99a942e3d81675b0e2b2c31f360aac01f36008f81a8a2ca4f13f02d02f42307df877704fdbce9f108659e0972ff7a8bcbe966ff5002186ab1051c97d1
|
|
7
|
+
data.tar.gz: f34d0e714b9194bbca3c279ebd8c34f5c387ecd5822b549e0e237c896def85ae98dd9d8195f67c37b33a3c027c0a6764d130ab30faeab5d2ab1b7c7ecd43b8b7
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.6] - 2026-11-02
|
|
11
|
+
|
|
12
|
+
### Security
|
|
13
|
+
|
|
14
|
+
- The daemon now runs only the commands that the CLI sends over its socket: `start`, `stop`, `restart`, `unmonitor`, `status`, `version` and `log_file`. Before, it called whatever method a line on the socket named, so anyone who could write to the socket could call any of the daemon's public methods, such as `instance_eval` with code of their own. The socket takes the daemon's umask, so with the usual umask of 022 only the daemon's own user could connect. Any other command now gets a `NoMethodError` back.
|
|
15
|
+
|
|
10
16
|
## [0.1.5] - 2026-11-01
|
|
11
17
|
|
|
12
18
|
### Removed
|
|
@@ -758,7 +764,8 @@ Initial release.
|
|
|
758
764
|
- Added the `bluepill` CLI with the `load`, `status`, `start`, `stop`, `restart`, `unmonitor`, `quit` and `log` commands.
|
|
759
765
|
- Added syslog logging.
|
|
760
766
|
|
|
761
|
-
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.1.
|
|
767
|
+
[unreleased]: https://github.com/bluepill-rb/bluepill/compare/v0.1.6...HEAD
|
|
768
|
+
[0.1.6]: https://github.com/bluepill-rb/bluepill/compare/v0.1.5...v0.1.6
|
|
762
769
|
[0.1.5]: https://github.com/bluepill-rb/bluepill/compare/v0.1.4...v0.1.5
|
|
763
770
|
[0.1.4]: https://github.com/bluepill-rb/bluepill/compare/v0.1.3...v0.1.4
|
|
764
771
|
[0.1.3]: https://github.com/bluepill-rb/bluepill/compare/v0.1.2...v0.1.3
|
data/lib/bluepill/application.rb
CHANGED
|
@@ -13,6 +13,12 @@ module Bluepill
|
|
|
13
13
|
# The commands that act on a process or group, and that the CLI sends
|
|
14
14
|
PROCESS_COMMANDS = [:start, :stop, :restart, :unmonitor, :status].freeze
|
|
15
15
|
|
|
16
|
+
# The commands that the daemon answers over its socket: the
|
|
17
|
+
# PROCESS_COMMANDS, and the version and log file that the CLI asks for
|
|
18
|
+
#
|
|
19
|
+
# @api private
|
|
20
|
+
DAEMON_COMMANDS = (PROCESS_COMMANDS + [:version, :log_file]).freeze
|
|
21
|
+
|
|
16
22
|
attr_accessor :name, :logger, :base_dir, :socket, :pid_file, :kill_timeout, :groups, :work_queue, :pids_dir, :log_file
|
|
17
23
|
|
|
18
24
|
# @!attribute [rw] name
|
|
@@ -298,8 +304,8 @@ module Bluepill
|
|
|
298
304
|
# The target is group:process and the process name may contain ':'
|
|
299
305
|
command, *args = client.readline.strip.split(':', 3).reject(&:empty?)
|
|
300
306
|
response = begin
|
|
301
|
-
|
|
302
|
-
mutex { public_send(
|
|
307
|
+
method = daemon_command(command)
|
|
308
|
+
mutex { public_send(method, *args) }
|
|
303
309
|
rescue StandardError => e
|
|
304
310
|
e
|
|
305
311
|
end
|
|
@@ -319,6 +325,25 @@ module Bluepill
|
|
|
319
325
|
end
|
|
320
326
|
end
|
|
321
327
|
|
|
328
|
+
# Return the one of the DAEMON_COMMANDS that a client's command names
|
|
329
|
+
#
|
|
330
|
+
# Anyone who can write to the socket can send any line, so only these
|
|
331
|
+
# commands may run, and not any other of the daemon's public methods.
|
|
332
|
+
#
|
|
333
|
+
# @param [String, nil] command the command, or nil for an empty line
|
|
334
|
+
#
|
|
335
|
+
# @raise [NoMethodError] if it names none of them
|
|
336
|
+
#
|
|
337
|
+
# @return [Symbol]
|
|
338
|
+
#
|
|
339
|
+
# @api private
|
|
340
|
+
def daemon_command(command)
|
|
341
|
+
# The backtrace is caller's lines, with no locations, so Ruby 3.1's
|
|
342
|
+
# error_highlight doesn't add a snippet of this file to the message
|
|
343
|
+
DAEMON_COMMANDS.detect { |name| name.to_s.eql?(command) } ||
|
|
344
|
+
raise(NoMethodError, "Unknown command `#{command}`", caller)
|
|
345
|
+
end
|
|
346
|
+
|
|
322
347
|
# Start the daemon
|
|
323
348
|
#
|
|
324
349
|
# It stops a previous daemon for the application, clears journal locks
|
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.1.6"
|
|
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 # =>
|
|
36
|
+
# Bluepill::Version.patch # => 6
|
|
37
37
|
#
|
|
38
38
|
# @return [Integer] the patch version
|
|
39
39
|
#
|
|
40
40
|
# @api public
|
|
41
41
|
def self.patch
|
|
42
|
-
|
|
42
|
+
6
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Return the pre-release version
|
|
@@ -55,7 +55,7 @@ module Bluepill
|
|
|
55
55
|
# Return the version's parts by name
|
|
56
56
|
#
|
|
57
57
|
# @example
|
|
58
|
-
# Bluepill::Version.to_h # => {major: 0, minor: 1, patch:
|
|
58
|
+
# Bluepill::Version.to_h # => {major: 0, minor: 1, patch: 6, pre: nil}
|
|
59
59
|
#
|
|
60
60
|
# @return [Hash{Symbol => Integer, nil}] the major, minor, patch and
|
|
61
61
|
# pre-release versions
|
|
@@ -73,7 +73,7 @@ module Bluepill
|
|
|
73
73
|
# Return the version's parts, without a missing pre-release version
|
|
74
74
|
#
|
|
75
75
|
# @example
|
|
76
|
-
# Bluepill::Version.to_a # => [0, 1,
|
|
76
|
+
# Bluepill::Version.to_a # => [0, 1, 6]
|
|
77
77
|
#
|
|
78
78
|
# @return [Array<Integer>] the parts of the version
|
|
79
79
|
#
|
|
@@ -85,9 +85,9 @@ module Bluepill
|
|
|
85
85
|
# Return the version as a string
|
|
86
86
|
#
|
|
87
87
|
# @example
|
|
88
|
-
# Bluepill::Version.to_s # => "0.1.
|
|
88
|
+
# Bluepill::Version.to_s # => "0.1.6"
|
|
89
89
|
#
|
|
90
|
-
# @return [String] the version, such as "0.1.
|
|
90
|
+
# @return [String] the version, such as "0.1.6"
|
|
91
91
|
#
|
|
92
92
|
# @api public
|
|
93
93
|
def self.to_s
|
data/sig/bluepill.rbs
CHANGED
|
@@ -41,6 +41,8 @@ module Bluepill
|
|
|
41
41
|
class Application
|
|
42
42
|
PROCESS_COMMANDS: Array[Symbol]
|
|
43
43
|
|
|
44
|
+
DAEMON_COMMANDS: Array[Symbol]
|
|
45
|
+
|
|
44
46
|
attr_accessor name: String
|
|
45
47
|
attr_accessor logger: Logger
|
|
46
48
|
attr_accessor base_dir: String
|
|
@@ -90,6 +92,8 @@ module Bluepill
|
|
|
90
92
|
|
|
91
93
|
def start_listener: () -> Thread
|
|
92
94
|
|
|
95
|
+
def daemon_command: (String? command) -> Symbol
|
|
96
|
+
|
|
93
97
|
def start_server: () -> void
|
|
94
98
|
|
|
95
99
|
def run: () -> void
|