]> git.cworth.org Git - sup/blob - lib/sup/suicide.rb
minor: move hook load messages from info to debug
[sup] / lib / sup / suicide.rb
1 module Redwood
2
3 class SuicideManager
4   include Singleton
5
6   DELAY = 5
7
8   def initialize fn
9     @fn = fn
10     @die = false
11     @thread = nil
12     FileUtils.rm_f @fn
13   end
14
15   bool_reader :die
16
17   def start
18     @thread = Redwood::reporting_thread("suicide watch") do
19       while true
20         sleep DELAY
21         if File.exists? @fn
22           FileUtils.rm_f @fn
23           @die = true
24         end
25       end
26     end
27   end
28
29   def stop
30     @thread.kill if @thread
31     @thread = nil
32   end
33 end
34
35 end