Class: RubySupervisor::ProcessProxy
- Inherits:
-
NamedProxy
- Object
- Proxy
- NamedProxy
- RubySupervisor::ProcessProxy
- Includes:
- ProcessLogsAPI
- Defined in:
- lib/ruby-supervisor/api/process.rb
Overview
Process Proxy.
Note: you can address programs in a group via this name: <group>:<process>
Constant Summary collapse
- STATE_TO_STR =
{ 0 => :stopped, 10 => :starting, 20 => :running, 30 => :backoff, 40 => :stopping, 100 => :exited, 200 => :fatal, 1000 => :unknown }.freeze
- STR_TO_STATE =
STATE_TO_STR.invert.freeze
Instance Attribute Summary
Attributes inherited from NamedProxy
Instance Method Summary collapse
-
#infos ⇒ Hash
Return informations about process.
-
#restart(wait = true, &block) ⇒ Object
Restart the process.
-
#send_stdin(data) ⇒ Object
Write data to the process standard input.
-
#start(wait = true) ⇒ Object
Start the process.
-
#state ⇒ Symbol
Return process state as symbol.
-
#stop(wait = true) ⇒ Object
Stop the process.
Methods included from ProcessLogsAPI
Methods inherited from NamedProxy
Methods inherited from Proxy
Constructor Details
This class inherits a constructor from RubySupervisor::NamedProxy
Instance Method Details
#infos ⇒ Hash
Return informations about process.
50 51 52 |
# File 'lib/ruby-supervisor/api/process.rb', line 50 def infos request('getProcessInfo', @name) end |
#restart(wait = true, &block) ⇒ Object
Restart the process. If you pass a block to this method it will get called after the actual restart. Be aware that wehn using a block with wait = false your block will be scheduled in a separate thread !
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ruby-supervisor/api/process.rb', line 84 def restart(wait = true, &block) if wait begin stop(true) ensure start(true) end block.call if block else Thread.new do stop(true) start(true) block.call if block end end end |
#send_stdin(data) ⇒ Object
Write data to the process standard input.
108 109 110 |
# File 'lib/ruby-supervisor/api/process.rb', line 108 def send_stdin(data) request('sendProcessStdin', @name, data) end |
#start(wait = true) ⇒ Object
Start the process.
60 61 62 |
# File 'lib/ruby-supervisor/api/process.rb', line 60 def start(wait = true) request('startProcess', @name, wait) end |
#state ⇒ Symbol
Return process state as symbol.
40 41 42 43 |
# File 'lib/ruby-supervisor/api/process.rb', line 40 def state state = infos['state'] STATE_TO_STR[ state ] end |
#stop(wait = true) ⇒ Object
Stop the process.
70 71 72 |
# File 'lib/ruby-supervisor/api/process.rb', line 70 def stop(wait = true) request('stopProcess', @name, wait) end |