Class: Nonnative::Process
Overview
Runtime runner that manages an OS-level child process.
A process runner:
- spawns a child process using the configured command and environment,
- waits briefly (via the runner
wait), and - participates in readiness/shutdown via TCP port checks orchestrated by Pool.
The underlying configuration is a ConfigurationProcess.
Instance Attribute Summary collapse
-
#memory ⇒ GetProcessMem?
readonly
Memory reader for the current process lifecycle.
Instance Method Summary collapse
-
#initialize(service) ⇒ Process
constructor
A new instance of Process.
-
#start ⇒ Array<(Integer, Boolean)>
Spawns the configured process if it is not already running.
-
#stop ⇒ Array<(Integer, Boolean)>
Stops the process if it is running.
Methods inherited from Runner
Constructor Details
Instance Attribute Details
#memory ⇒ GetProcessMem? (readonly)
Returns memory reader for the current process lifecycle.
24 25 26 |
# File 'lib/nonnative/process.rb', line 24 def memory @memory end |
Instance Method Details
#start ⇒ Array<(Integer, Boolean)>
Spawns the configured process if it is not already running.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nonnative/process.rb', line 32 def start unless process_exists? @pid = process_spawn # Keep memory reads bound to the child spawned for this lifecycle. @memory = GetProcessMem.new(pid) wait_start end [pid, ::Process.waitpid2(pid, ::Process::WNOHANG).nil?] end |
#stop ⇒ Array<(Integer, Boolean)>
Stops the process if it is running.
The process is signalled using the configured signal (defaults to INT when not set).
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nonnative/process.rb', line 51 def stop stopped = true if process_exists? process_kill stopped = wait_stop != false force_stop unless stopped end [pid, stopped] ensure @memory = nil end |