]> gitweb.factorcode.org Git - factor.git/blob - extra/mason/mason.factor
factor: Make source files/resources 644 instead of 755.
[factor.git] / extra / mason / mason.factor
1 ! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar continuations debugger io
4 io.directories io.sockets io.streams.string kernel mason.build
5 mason.config mason.disk mason.email mason.notify mason.updates
6 namespaces prettyprint threads ;
7 IN: mason
8
9 : heartbeat-loop ( -- )
10     notify-heartbeat
11     5 minutes sleep
12     heartbeat-loop ;
13
14 : fatal-error-body ( error callstack -- string )
15     [
16         "Fatal error on " write host-name print nl
17         [ error. ] [ callstack. ] bi*
18     ] with-string-writer ;
19
20 : build-loop-error ( error callstack -- )
21     fatal-error-body
22      "build loop error"
23      email-fatal ;
24
25 : build-loop ( -- )
26     [
27         builds-dir get make-directories
28         builds-dir get [
29             check-disk-space
30             update-sources
31             should-build? [ do-build ] [ 5 minutes sleep ] if
32         ] with-directory
33     ] [
34         error-continuation get call>> build-loop-error
35         5 minutes sleep
36     ] recover
37
38     build-loop ;
39
40 : run-mason ( -- )
41     [ heartbeat-loop ] "Heartbeat loop" spawn
42     [ build-loop ] "Build loop" spawn
43     stop ;
44
45 MAIN: run-mason