Class: Async::Container::Process::Instance

Inherits:
Notify::Pipe show all
Defined in:
lib/async/container/process.rb

Constant Summary

Constants inherited from Notify::Pipe

Notify::Pipe::NOTIFY_PIPE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Notify::Pipe

#before_spawn, open!, #ready!, #reloading!, #send

Methods inherited from Notify::Client

#error!, #ready!, #reloading!, #restarting!, #status!, #stopping!

Constructor Details

#initialize(io) ⇒ Instance

Returns a new instance of Instance.



41
42
43
44
45
# File 'lib/async/container/process.rb', line 41

def initialize(io)
  super
  
  @name = nil
end

Class Method Details

.for(process) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/async/container/process.rb', line 30

def self.for(process)
  instance = self.new(process.out)
  
  # The child process won't be reading from the channel:
  process.close_read
  
  instance.name = process.name
  
  return instance
end

Instance Method Details

#exec(*arguments, ready: true, **options) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/async/container/process.rb', line 57

def exec(*arguments, ready: true, **options)
  if ready
    self.ready!(status: "(exec)") if ready
  else
    self.before_spawn(arguments, options)
  end
  
  ::Process.exec(*arguments, options)
end

#nameObject



53
54
55
# File 'lib/async/container/process.rb', line 53

def name
  @name
end

#name=(value) ⇒ Object



47
48
49
50
51
# File 'lib/async/container/process.rb', line 47

def name= value
  if @name = value
    ::Process.setproctitle(@name)
  end
end