Watchdog script - 30/06/05 02:50 AM
I've not seen anything like this, so I thought others would appreciate seeing the script I've come up with... The script stops events from happening for five minutes, if a timer that runs every 5 seconds starts to overlap when the following occurance of the timer should occur.
Code:
on *:start:{ .timer 0 5 watchdog } alias watchdog { ; Setup a $tick monitoring watchdog if (!%~WatchdogOffTime) { set %~WatchdogOffTime 5 } if (!%~WatchdogTickCount) { set %~WatchdogTickCount 10000 } if (!$timer(Watchdog)) && (%~LastTicksWatchdog) && ($calc($ticks - %~LastTicksWatchdog) > %~WatchdogTickCount) { .remote off | .timerWatchDog off | .timerWatchdog 1 $calc(%~WatchdogOffTime * 60) reenable.remote echo -a Disabling all script events because of watchdog. Elapsed = $calc($ticks - %~LastTicksWatchdog)) $+ . echo -a Will automatically reenable in %~WatchdogOffTime minutes. } else { set %~LastTicksWatchdog $ticks } } alias reenable.remote { .timerWatchdog off set %~LastTicksWatchdog $ticks .remote on echo -a Watchdog has reenabled event processing. }