Class: Nonnative::Process
Overview
Runtime runner that manages an OS-level child process.
A process runner:
-
starts the configured proxy (if any),
-
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
Attributes inherited from Runner
Instance Method Summary collapse
-
#initialize(service) ⇒ Process
constructor
A new instance of Process.
-
#memory ⇒ GetProcessMem?
Returns a memoized memory reader for the spawned process.
-
#start ⇒ Array<(Integer, Boolean)>
Starts the proxy (if any) and spawns the configured process if it is not already running.
-
#stop ⇒ Integer?
Stops the process (if running) and stops the proxy (if any).
Methods inherited from Runner
Constructor Details
Instance Method Details
#memory ⇒ GetProcessMem?
Returns a memoized memory reader for the spawned process.
This is primarily used by acceptance tests to assert memory usage.
61 62 63 64 65 |
# File 'lib/nonnative/process.rb', line 61 def memory return if pid.nil? @memory ||= GetProcessMem.new(pid) end |
#start ⇒ Array<(Integer, Boolean)>
Starts the proxy (if any) and spawns the configured process if it is not already running.
30 31 32 33 34 35 36 37 38 |
# File 'lib/nonnative/process.rb', line 30 def start unless process_exists? proxy.start @pid = process_spawn wait_start end [pid, ::Process.waitpid2(pid, ::Process::WNOHANG).nil?] end |
#stop ⇒ Integer?
Stops the process (if running) and stops the proxy (if any).
The process is signalled using the configured signal (defaults to ‘INT` when not set).
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nonnative/process.rb', line 45 def stop if process_exists? process_kill wait_stop end pid ensure proxy.stop end |