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

http://github.com/abeaumont/factor · Factor · 36 lines · 29 code · 5 blank · 2 comment · 2 complexity · fe7745b8e8079a6d004c9e6860350442 MD5 · raw file

  1. ! Copyright (C) 2010 Slava Pestov.
  2. ! See http://factorcode.org/license.txt for BSD license.
  3. USING: kernel math math.parser sequences xml.syntax xml.writer
  4. mason.email webapps.mason.backend ;
  5. IN: webapps.mason.backend.watchdog
  6. : crashed-builder-body ( crashed-builders -- string content-type )
  7. [ os/cpu [XML <li><-></li> XML] ] map
  8. <XML
  9. <html>
  10. <body>
  11. <p>Machines which are not sending heartbeats:</p>
  12. <ul><-></ul>
  13. <a href="http://builds.factorcode.org/dashboard">Dashboard</a>
  14. </body>
  15. </html>
  16. XML> xml>string
  17. "text/html" ;
  18. : s ( n before after -- string )
  19. pick 1 > [ "s" append ] when
  20. [ number>string ] 2dip surround ;
  21. : crashed-builder-subject ( crashed-builders -- string )
  22. length "Take note: " " crashed build machine" s ;
  23. : send-crashed-builder-email ( crashed-builders -- )
  24. [ crashed-builder-body ]
  25. [ crashed-builder-subject ] bi
  26. mason-email ;
  27. : check-builders ( -- )
  28. [
  29. funny-builders drop
  30. [ send-crashed-builder-email ] unless-empty
  31. ] with-mason-db ;