Class: Redwood::SuicideManager
- Inherits:
-
Object
- Object
- Redwood::SuicideManager
- Includes:
- Singleton
- Defined in:
- lib/sup/suicide.rb
Constant Summary
- DELAY =
5
Instance Method Summary (collapse)
-
- (SuicideManager) initialize(fn)
constructor
A new instance of SuicideManager.
- - (Object) start
- - (Object) stop
Constructor Details
- (SuicideManager) initialize(fn)
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
- (Object) start
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 |
- (Object) stop
30 31 32 33 |
# File 'lib/sup/suicide.rb', line 30 def stop @thread.kill if @thread @thread = nil end |