PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/extra/webapps/mason/backend/watchdog/watchdog.factor

http://github.com/abeaumont/factor
Unknown | 36 lines | 31 code | 5 blank | 0 comment | 0 complexity | fe7745b8e8079a6d004c9e6860350442 MD5 | raw file
 1! Copyright (C) 2010 Slava Pestov.
 2! See http://factorcode.org/license.txt for BSD license.
 3USING: kernel math math.parser sequences xml.syntax xml.writer
 4mason.email webapps.mason.backend ;
 5IN: 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        <html>
11            <body>
12                <p>Machines which are not sending heartbeats:</p>
13                <ul><-></ul>
14                <a href="http://builds.factorcode.org/dashboard">Dashboard</a>
15            </body>
16        </html>
17    XML> xml>string
18    "text/html" ;
19
20: s ( n before after -- string )
21    pick 1 > [ "s" append ] when
22    [ number>string ] 2dip surround ;
23
24: crashed-builder-subject ( crashed-builders -- string )
25    length "Take note: " " crashed build machine" s ;
26
27: send-crashed-builder-email ( crashed-builders -- )
28    [ crashed-builder-body ]
29    [ crashed-builder-subject ] bi
30    mason-email ;
31
32: check-builders ( -- )
33    [
34        funny-builders drop
35        [ send-crashed-builder-email ] unless-empty
36    ] with-mason-db ;