! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alarms arrays calendar combinators
-combinators.smart continuations debugger http.client fry
-init io.streams.string kernel locals math math.parser db
-namespaces sequences site-watcher.db site-watcher.email ;
+USING: accessors calendar continuations db http.client init
+kernel math math.parser namespaces sequences site-watcher.db
+site-watcher.email timers ;
IN: site-watcher
SYMBOL: site-watcher-frequency
5 minutes site-watcher-frequency set-global
-
+
SYMBOL: running-site-watcher
[ f running-site-watcher set-global ] "site-watcher" add-startup-hook
send-site-email ;
: send-reports ( seq -- )
- [ ] [ [ send-report ] each ] if-empty ;
+ [ [ send-report ] each ] unless-empty ;
PRIVATE>
find-sites check-sites sites-to-report send-reports ;
: run-site-watcher ( db -- )
- [ running-site-watcher get ] dip '[
+ [ running-site-watcher get ] dip '[
[ _ [ watch-sites ] with-db ] site-watcher-frequency get every
running-site-watcher set
] unless ;
: stop-site-watcher ( -- )
- running-site-watcher get [ cancel-alarm ] when* ;
+ running-site-watcher get [ stop-timer ] when* ;