Class: October::Watchdog
- Inherits:
-
Object
- Object
- October::Watchdog
- Defined in:
- lib/october/watchdog.rb
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root, env = nil) ⇒ Watchdog
constructor
A new instance of Watchdog.
- #loop! ⇒ Object
- #spawn! ⇒ Object
Constructor Details
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
3 4 5 |
# File 'lib/october/watchdog.rb', line 3 def child @child end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
3 4 5 |
# File 'lib/october/watchdog.rb', line 3 def env @env end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/october/watchdog.rb', line 3 def root @root end |
Instance Method Details
#loop! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/october/watchdog.rb', line 21 def loop! loop do begin Process.wait(spawn!) warn "process #{child} ended" rescue Errno::ECHILD warn "process #{child} died or was killed" end warn "spawning new one in next iteration" sleep(1) # throttle spawning in case anything fails end end |