Class: Redwood::SuicideManager
- Includes:
- Singleton
- Defined in:
- lib/sup/suicide.rb
Constant Summary collapse
- DELAY =
5
Instance Method Summary collapse
-
#initialize(fn) ⇒ SuicideManager
constructor
A new instance of SuicideManager.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(fn) ⇒ SuicideManager
Returns a new instance of SuicideManager.
8 9 10 11 12 13 14 |
# File 'lib/sup/suicide.rb', line 8 def initialize fn @fn = fn @die = false @thread = nil self.class.i_am_the_instance self FileUtils.rm_f @fn end |
Instance Method Details
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sup/suicide.rb', line 18 def start @thread = Redwood::reporting_thread("suicide watch") do while true sleep DELAY if File.exists? @fn FileUtils.rm_f @fn @die = true end end end end |
#stop ⇒ Object
30 31 32 33 |
# File 'lib/sup/suicide.rb', line 30 def stop @thread.kill if @thread @thread = nil end |