56 lines
1.1 KiB
Text
56 lines
1.1 KiB
Text
|
"#time.spl" import
|
||
|
|
||
|
"home node management" =program-name
|
||
|
|
||
|
def remote, revpfwkey
|
||
|
|
||
|
"revpfw.spl" import
|
||
|
"network.spl" import
|
||
|
|
||
|
"tudbut.de" =remote
|
||
|
"REVPFWKEY" env:get =revpfwkey
|
||
|
|
||
|
func panic-handler { |
|
||
|
|
||
|
}
|
||
|
|
||
|
func main { exitcode | with args ;
|
||
|
"management system starting up." println
|
||
|
"init revpfw subsystem" println
|
||
|
&revpfw-watcher fork
|
||
|
1000 time:sleep;
|
||
|
"init ircbot subsystem" println
|
||
|
&ircbot-watcher fork
|
||
|
1000 time:sleep;
|
||
|
"init network monitor subsystem" println
|
||
|
&network-monitor fork
|
||
|
1000 time:sleep;
|
||
|
}
|
||
|
|
||
|
func watcher { | with statevar update delay ;
|
||
|
while { statevar call =>? [ ^ok &pop ] } {
|
||
|
def sa time:unixms =sa
|
||
|
update call
|
||
|
delay (time:unixms sa -) - dup 0 lt if { pop 0 } time:sleep;
|
||
|
}
|
||
|
:sjson<0> panic
|
||
|
}
|
||
|
|
||
|
func revpfw-watcher { |
|
||
|
[ ^ok ^down ] =revpfw-state
|
||
|
&revpfw-state &revpfw-update watcher<1000>
|
||
|
}
|
||
|
|
||
|
func ircbot-watcher { |
|
||
|
"ircbot -> service disabled" println
|
||
|
1 stop
|
||
|
|
||
|
[ ^ok ^down ] =ircbot-state
|
||
|
&ircbot-state &ircbot-update watcher<1000>
|
||
|
}
|
||
|
|
||
|
func network-monitor { |
|
||
|
[ ^ok ^up ] =network-state
|
||
|
&network-state &network-update watcher<30000>
|
||
|
}
|