Changeset 20 for TriviaEngine


Ignore:
Timestamp:
10/08/06 09:40:20 (6 years ago)
Author:
james
Message:

fix watchdog stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TriviaEngine/TriviaEngine-sqlite.tcl

    r19 r20  
    13481348proc trivia_watchdog { } { 
    13491349#<<< 
    1350         global trivia_last_ts trivia_watchdog_timer trivia_status trivia_channel 
     1350        global trivia_last_ts trivia_watchdog_timer trivia_status trivia_channel trivia_delay trivia_speed 
    13511351 
    13521352        putloglev d * "trivia watchdog: tick" 
    13531353 
    1354         if {$trivia_last_ts == 0} { 
    1355                 #never asked a question 
     1354        # slow down if we've never asked a question or we're stopped 
     1355        if {($trivia_last_ts == 0) || ($trivia_status == 0)} { 
     1356                putloglev 1 * "trivia is not running, slowing down watchdog" 
    13561357                set trivia_watchdog_timer [utimer 45 trivia_watchdog] 
    13571358                return 0 
     
    13611362        set difference [expr $current_ts - $trivia_last_ts] 
    13621363 
    1363         if {$difference > 0} { 
     1364        set trivia_limit [expr $trivia_delay + $trivia_speed + 5] 
     1365 
     1366        putloglev 1 * "trivia watchdog: current: $current_ts, last: $trivia_last_ts, difference: $difference, max: $trivia_limit" 
     1367 
     1368        if {$difference > $trivia_limit} { 
    13641369                if {$trivia_status == 1} { 
    13651370                        putlog "watchdog: trivia is broken" 
    1366                         #putserv "PRIVMSG $trivia_channel :Oops, I think I'm broken. Attempting to recover..." 
    1367                         #set trivia_status 0 
    1368                         #trivia_start 
    1369                         putlog "trivia watchdog: current: $current_ts, last: $trivia_last_ts, difference: $difference" 
    1370                 } 
    1371         } 
     1371                        putquick "PRIVMSG $trivia_channel :Oops, I think I'm broken. Attempting to recover..." 
     1372                        set trivia_status 0 
     1373                        trivia_start 
     1374                } 
     1375        } 
     1376 
     1377        set timer_interval [expr $trivia_delay * 2] 
    13721378 
    13731379        set trivia_watchdog_timer [utimer 10 trivia_watchdog] 
     
    13811387        global trivia_watchdog_timer 
    13821388 
    1383         if {$trivia_watchdog_timer != ""} { 
    1384                 killutimer $trivia_watchdog_timer 
    1385         } 
     1389  set alltimers [utimers] 
     1390  foreach t $alltimers { 
     1391    putloglev 1 * "checking timer $t" 
     1392    set t_function [lindex $t 1] 
     1393    set t_name [lindex $t 2] 
     1394    set t_function [string tolower $t_function] 
     1395                if {$t_function == "trivia_watchdog"} { 
     1396                        putloglev d * "killing timer $t_name" 
     1397      killutimer $t_name 
     1398                } 
     1399  } 
     1400 
     1401        unset trivia_watchdog_timer 
    13861402} 
    13871403#>>> 
Note: See TracChangeset for help on using the changeset viewer.