Class: Async::Container::Process::Instance
- Inherits:
-
Notify::Pipe
- Object
- Notify::Client
- Notify::Pipe
- Async::Container::Process::Instance
- Defined in:
- lib/async/container/process.rb
Overview
Represents a running child process from the point of view of the child process.
Constant Summary
Constants inherited from Notify::Pipe
Class Method Summary collapse
-
.for(process) ⇒ Object
Wrap an instance around the Async::Container::Process instance from within the forked child.
Instance Method Summary collapse
-
#exec(*arguments, ready: true, **options) ⇒ Object
Replace the current child process with a different one.
-
#initialize(io) ⇒ Instance
constructor
A new instance of Instance.
-
#name ⇒ Object
The name of the process.
-
#name=(value) ⇒ Object
Set the process title to the specified value.
Methods inherited from Notify::Pipe
Methods inherited from Notify::Client
#error!, #ready!, #reloading!, #restarting!, #status!, #stopping!
Constructor Details
#initialize(io) ⇒ Instance
Returns a new instance of Instance.
47 48 49 50 51 |
# File 'lib/async/container/process.rb', line 47 def initialize(io) super @name = nil end |
Class Method Details
.for(process) ⇒ Object
Wrap an instance around the Async::Container::Process instance from within the forked child.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/async/container/process.rb', line 36 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
Replace the current child process with a different one. Forwards arguments and options to Process.exec. This method replaces the child process with the new executable, thus this method never returns.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/async/container/process.rb', line 69 def exec(*arguments, ready: true, **) if ready self.ready!(status: "(exec)") if ready else self.before_spawn(arguments, ) end # TODO prefer **options... but it doesn't support redirections on < 2.7 ::Process.exec(*arguments, ) end |
#name ⇒ Object
The name of the process.
63 64 65 |
# File 'lib/async/container/process.rb', line 63 def name @name end |
#name=(value) ⇒ Object
Set the process title to the specified value.
55 56 57 58 59 |
# File 'lib/async/container/process.rb', line 55 def name= value if @name = value ::Process.setproctitle(@name) end end |