]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
ircbot: SIGUSR1 forces a reconnect
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 15 Jan 2009 03:46:50 +0000 (04:46 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 15 Jan 2009 03:48:36 +0000 (04:48 +0100)
lib/rbot/ircbot.rb

index 0ae1bce0e424028f4656ffe7f2f09d94152ed1c9..098a72921be3c35cb50310e74553fb9fb929f99c 100644 (file)
@@ -829,7 +829,8 @@ class Bot
   # things to do when we receive a signal
   def got_sig(sig, func=:quit)
     debug "received #{sig}, queueing #{func}"
-    $interrupted += 1
+    # this is not an interruption if we just need to reconnect
+    $interrupted += 1 unless func == :reconnect
     self.send(func) unless @quit_mutex.locked?
     debug "interrupted #{$interrupted} times"
     if $interrupted >= 3
@@ -845,6 +846,7 @@ class Bot
       trap("SIGINT") { got_sig("SIGINT") }
       trap("SIGTERM") { got_sig("SIGTERM") }
       trap("SIGHUP") { got_sig("SIGHUP", :restart) }
+      trap("SIGUSR1") { got_sig("SIGUSR1", :reconnect) }
     rescue ArgumentError => e
       debug "failed to trap signals (#{e.pretty_inspect}): running on Windows?"
     rescue Exception => e