bluepill 0.3.0 → 0.3.2

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/README.md +4 -6
  4. data/bin/bluepill +13 -6
  5. data/bluepill.gemspec +7 -2
  6. data/lib/bluepill/application/lifecycle.rb +8 -5
  7. data/lib/bluepill/application/listener.rb +1 -3
  8. data/lib/bluepill/application.rb +5 -3
  9. data/lib/bluepill/condition_watch.rb +3 -2
  10. data/lib/bluepill/controller.rb +5 -2
  11. data/lib/bluepill/daemonize.rb +52 -0
  12. data/lib/bluepill/dsl/attributes.rb +2 -2
  13. data/lib/bluepill/dsl/process_factory/child_factory.rb +5 -2
  14. data/lib/bluepill/dsl/process_factory/registry.rb +0 -2
  15. data/lib/bluepill/dsl/process_factory.rb +3 -1
  16. data/lib/bluepill/dsl/process_proxy.rb +28 -1
  17. data/lib/bluepill/dsl.rb +2 -2
  18. data/lib/bluepill/logger.rb +10 -2
  19. data/lib/bluepill/process/children.rb +2 -1
  20. data/lib/bluepill/process/pid.rb +2 -0
  21. data/lib/bluepill/process/stop_signals.rb +5 -2
  22. data/lib/bluepill/process/triggers.rb +2 -2
  23. data/lib/bluepill/process/watches.rb +2 -2
  24. data/lib/bluepill/process.rb +2 -2
  25. data/lib/bluepill/process_commands/execution.rb +4 -4
  26. data/lib/bluepill/process_commands.rb +1 -1
  27. data/lib/bluepill/process_conditions/file_time.rb +1 -1
  28. data/lib/bluepill/process_conditions/http.rb +2 -1
  29. data/lib/bluepill/socket.rb +1 -1
  30. data/lib/bluepill/system/command_options.rb +5 -4
  31. data/lib/bluepill/system/command_result.rb +1 -1
  32. data/lib/bluepill/system/command_spawn.rb +244 -0
  33. data/lib/bluepill/system/commands.rb +6 -22
  34. data/lib/bluepill/system/daemon.rb +79 -2
  35. data/lib/bluepill/system/usage.rb +20 -0
  36. data/lib/bluepill/version.rb +11 -11
  37. data/sig/bluepill/dsl.rbs +4 -0
  38. data/sig/bluepill/system.rbs +48 -13
  39. data/sig/bluepill.rbs +1 -0
  40. metadata +3 -2
@@ -6,6 +6,10 @@ module Bluepill
6
6
 
7
7
  MAX_FD: Integer
8
8
 
9
+ DAEMON_ENV: String
10
+
11
+ def self.can_fork?: () -> bool
12
+
9
13
  def self.safefork: () -> Integer?
10
14
 
11
15
  def self.call_as_daemon: (^() -> void block, ?String? name) -> Integer
@@ -16,6 +20,10 @@ module Bluepill
16
20
 
17
21
  def self.daemonize: () -> Integer
18
22
 
23
+ def self.daemonize_without_fork: () -> Integer
24
+
25
+ def self.start_daemon_bluepill: () -> bot
26
+
19
27
  def self.detach: () -> Integer
20
28
 
21
29
  def self.become_daemon: (?String? name) -> void
@@ -54,17 +62,7 @@ module Bluepill
54
62
  # Hooks are killed after this many seconds
55
63
  attr_reader timeout: seconds?
56
64
 
57
- def initialize: (
58
- ?uid: String?,
59
- ?gid: String?,
60
- ?supplementary_groups: Array[String]?,
61
- ?working_dir: String?,
62
- ?environment: Hash[_ToS, _ToS]?,
63
- ?stdin: String?,
64
- ?stdout: String?,
65
- ?stderr: String?,
66
- ?timeout: seconds?
67
- ) -> void
65
+ def initialize: (?uid: String?, ?gid: String?, ?supplementary_groups: Array[String]?, ?working_dir: String?, ?environment: Hash[_ToS, _ToS]?, ?stdin: String?, ?stdout: String?, ?stderr: String?, ?timeout: seconds?) -> void
68
66
 
69
67
  def for_hook: (Hash[String, String] env, seconds timeout) -> CommandOptions
70
68
 
@@ -162,6 +160,8 @@ module Bluepill
162
160
  module Usage : Ps
163
161
  def pid_alive?: (Integer pid) -> bool
164
162
 
163
+ def reap: (Integer? pid) -> void
164
+
165
165
  def started_at: (Integer pid) -> Integer?
166
166
 
167
167
  def boot_time: () -> Integer?
@@ -197,13 +197,49 @@ module Bluepill
197
197
  def switch_to_user: (Etc::Passwd user) -> void
198
198
  end
199
199
 
200
+ # Starts commands without forking, in a Ruby that can't fork
201
+ module CommandSpawn
202
+ EXIT_POLL_INTERVAL: Float
203
+
204
+ def spawn_command: (String cmd, CommandOptions options, ?chdir: String?, **untyped redirects) -> Integer
205
+
206
+ def spawn_blocking: (String cmd, CommandOptions options) -> CommandResult
207
+
208
+ def run_spawned: (String cmd, CommandOptions options, Array[IO] readers, [IO, IO] writers) -> CommandResult
209
+
210
+ def spawn_blocking_command: (String cmd, CommandOptions options, IO out, IO err) -> Integer
211
+
212
+ def wait_for_spawned: (String cmd, seconds? timeout, Integer pid, Array[IO] pipes) -> CommandResult
213
+
214
+ def wait_for_exit: (Integer pid, seconds? timeout) -> Process::Status?
215
+
216
+ def kill_spawned_after: (Integer pid, seconds? timeout, String cmd) -> bot
217
+
218
+ def kill_group_after: (Integer child, seconds? timeout, String cmd) -> bot
219
+
220
+ def monotonic_now: () -> Float
221
+
222
+ def read_in_background: (IO reader) -> Thread
223
+
224
+ def spawn_environment: (CommandOptions options) -> Hash[String, String]
225
+ end
226
+
200
227
  # Runs commands in the background, as daemons
201
228
  module Daemon
202
229
  include CommandSetup
230
+ include CommandSpawn
203
231
 
204
232
  # Returns the daemon's pid
205
233
  def daemonize: (String cmd, ?CommandOptions options, pid_file: String, logger: Logger) -> Integer?
206
234
 
235
+ def fork_daemon: (String cmd, CommandOptions options, pid_file: String, logger: Logger) -> Integer?
236
+
237
+ def spawn_daemon: (String cmd, CommandOptions options, pid_file: String, logger: Logger) -> Integer?
238
+
239
+ def daemon_streams: (CommandOptions options) -> Hash[Symbol, untyped]
240
+
241
+ def daemon_stderr: (String? out, String? err) -> untyped
242
+
207
243
  def read_daemon_pid: (IO reader, IO writer) -> Integer?
208
244
 
209
245
  def start_daemon: (String cmd, CommandOptions options, IO pid_pipe, pid_file: String, logger: Logger) -> bot
@@ -218,6 +254,7 @@ module Bluepill
218
254
  # Runs commands until they finish
219
255
  module Commands
220
256
  include CommandSetup
257
+ include CommandSpawn
221
258
 
222
259
  def execute_blocking: (String cmd, ?CommandOptions options) -> CommandResult
223
260
 
@@ -225,8 +262,6 @@ module Bluepill
225
262
 
226
263
  def read_blocking_status: (String cmd, seconds? timeout, Integer child, IO reader) -> String
227
264
 
228
- def kill_group_after: (Integer child, seconds? timeout, String cmd) -> bot
229
-
230
265
  def run_blocking_child: (String cmd, CommandOptions options, IO result_pipe) -> bot
231
266
 
232
267
  def collect_blocking_result: (Integer pid, IO cmd_out_read, IO cmd_err_read) -> blocking_result
data/sig/bluepill.rbs CHANGED
@@ -99,6 +99,7 @@ class Integer
99
99
  include Bluepill::Units
100
100
  end
101
101
 
102
+ # So Float multiplies by the units too
102
103
  class Float
103
104
  include Bluepill::Units
104
105
  end
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.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar
@@ -93,6 +93,7 @@ files:
93
93
  - lib/bluepill/system/command_options.rb
94
94
  - lib/bluepill/system/command_result.rb
95
95
  - lib/bluepill/system/command_setup.rb
96
+ - lib/bluepill/system/command_spawn.rb
96
97
  - lib/bluepill/system/commands.rb
97
98
  - lib/bluepill/system/daemon.rb
98
99
  - lib/bluepill/system/files.rb
@@ -134,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
135
  requirements:
135
136
  - - ">="
136
137
  - !ruby/object:Gem::Version
137
- version: '3.0'
138
+ version: '3.2'
138
139
  required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  requirements:
140
141
  - - ">="