Class: Redwood::SuicideManager

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sup/suicide.rb

Constant Summary

DELAY =
5

Instance Method Summary collapse

Constructor Details

#initialize(fn) ⇒ 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

#startObject



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

#stopObject



30
31
32
33
# File 'lib/sup/suicide.rb', line 30

def stop
  @thread.kill if @thread
  @thread = nil
end