Class: Nonnative::Process

Inherits:
Runner
  • Object
show all
Defined in:
lib/nonnative/process.rb

Instance Attribute Summary

Attributes inherited from Runner

#proxy

Instance Method Summary collapse

Methods inherited from Runner

#name

Constructor Details

#initialize(service) ⇒ Process

Returns a new instance of Process.



5
6
7
8
9
# File 'lib/nonnative/process.rb', line 5

def initialize(service)
  super

  @timeout = Nonnative::Timeout.new(service.timeout)
end

Instance Method Details

#memoryObject



31
32
33
34
35
# File 'lib/nonnative/process.rb', line 31

def memory
  return if pid.nil?

  @memory ||= GetProcessMem.new(pid)
end

#startObject



11
12
13
14
15
16
17
18
19
# File 'lib/nonnative/process.rb', line 11

def start
  unless process_exists?
    proxy.start
    @pid = process_spawn
    wait_start
  end

  [pid, ::Process.waitpid2(pid, ::Process::WNOHANG).nil?]
end

#stopObject



21
22
23
24
25
26
27
28
29
# File 'lib/nonnative/process.rb', line 21

def stop
  if process_exists?
    process_kill
    proxy.stop
    wait_stop
  end

  pid
end