]> gitweb.factorcode.org Git - factor.git/blob - extra/webapps/mason/backend/watchdog/watchdog.factor
Switch to https urls
[factor.git] / extra / webapps / mason / backend / watchdog / watchdog.factor
1 ! Copyright (C) 2010 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: formatting kernel mason.email math sequences
4 webapps.mason.backend xml.syntax xml.writer ;
5 IN: webapps.mason.backend.watchdog
6
7 : crashed-builder-body ( crashed-builders -- string content-type )
8     [ os/cpu [XML <li><-></li> XML] ] map
9     <XML
10         <!DOCTYPE html>
11         <html>
12             <body>
13                 <p>Machines which are not sending heartbeats:</p>
14                 <ul><-></ul>
15                 <a href="https://builds.factorcode.org/dashboard">Dashboard</a>
16             </body>
17         </html>
18     XML> xml>string
19     "text/html" ;
20
21 : crashed-builder-subject ( crashed-builders -- string )
22     length dup 1 > "" "s" ?
23     "Take note: %d crashed build machine%s" sprintf ;
24
25 : send-crashed-builder-email ( crashed-builders -- )
26     [ crashed-builder-body ]
27     [ crashed-builder-subject ] bi
28     mason-email ;
29
30 : check-builders ( -- )
31     [
32         funny-builders drop
33         [ send-crashed-builder-email ] unless-empty
34     ] with-mason-db ;