Class: RTwatchdog::Daemon
- Inherits:
-
Object
- Object
- RTwatchdog::Daemon
- Defined in:
- lib/rt_watchdog/daemon.rb
Instance Method Summary collapse
- #ram ⇒ Object
- #ram_too_big? ⇒ Boolean
- #restart ⇒ Object
- #run ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Instance Method Details
#ram ⇒ Object
38 39 40 |
# File 'lib/rt_watchdog/daemon.rb', line 38 def ram `#{RTwatchdog::RAM}`.to_i end |
#ram_too_big? ⇒ Boolean
46 47 48 |
# File 'lib/rt_watchdog/daemon.rb', line 46 def ram_too_big? ram > RTwatchdog::MAX_RAM end |
#restart ⇒ Object
33 34 35 36 |
# File 'lib/rt_watchdog/daemon.rb', line 33 def restart stop start end |
#run ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rt_watchdog/daemon.rb', line 5 def run trap('TERM') do stop exit end loop do start unless running? restart if ram_too_big? sleep 2 end end |
#running? ⇒ Boolean
42 43 44 |
# File 'lib/rt_watchdog/daemon.rb', line 42 def running? `#{RTwatchdog::RUNNING}`.length > 0 end |
#start ⇒ Object
19 20 21 |
# File 'lib/rt_watchdog/daemon.rb', line 19 def start `#{RTwatchdog::START}` end |
#stop ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/rt_watchdog/daemon.rb', line 23 def stop begin Timeout::timeout RTwatchdog::TIMEOUT do `#{RTwatchdog::STOP}` end rescue Timeout::Error `#{RTwatchdog::REALLY_STOP}` end end |