experiments/layered-server-config

This commit is contained in:
Tony Garnock-Jones 2022-02-04 17:06:54 +01:00
parent 391109dc66
commit 38753f241c
8 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# Experimenting with service groups
syndicate-server -c ./boot

View File

@ -0,0 +1,10 @@
; To "run" a milestone service,
; - assert that it is both started and ready
; - that's it!
;
? <run-service <milestone ?m>> [
<service-state <milestone $m> started>
<service-state <milestone $m> ready>
$log ! <log "-" { service: <milestone $m> state: up }>
?- <log "-" { service: <milestone $m> state: down }>
]

View File

@ -0,0 +1,4 @@
; To the usual suite of service states we add `up`, meaning "either `ready` or `complete`".
;
? <service-state ?x ready> <service-state $x up>
? <service-state ?x complete> <service-state $x up>

View File

@ -0,0 +1,28 @@
; Attenuate `$config` by rewriting plain `require-service` assertions to
; `require-system-service` assertions. Allow all other assertions through.
;
let ?sys = <* $config [
<rewrite <require-service ?s> <require-system-service $s>>
<filter _>
]>
; Give meaning to `require-system-service`: it is an ordinary `require-service`, plus a
; declaration that the `system-layer` milestone depends on the service.
;
? <require-system-service ?s> [
<depends-on <milestone system-layer> <service-state $s up>>
<require-service $s>
]
; Load config in the `system-layer` directory, using the wrapped `config` so that all plain
; services required are changed to be *system* services.
;
<require-service <config-watcher "./system-layer" {
config: $sys
gatekeeper: $gatekeeper
log: $log
}>>
; In addition, require the `system-layer` milestone explicitly.
;
<require-service <milestone system-layer>>

View File

@ -0,0 +1,26 @@
; Attenuate `$config` by rewriting plain `require-service` assertions to
; `require-basic-service` assertions. Allow all other assertions through.
;
let ?basic = <* $config [
<rewrite <require-service ?s> <require-basic-service $s>>
<filter _>
]>
; Give meaning to `require-basic-service`: it is an ordinary `require-service`, plus a
; declaration that the service depends on the `system-layer` milestone.
;
? <require-basic-service ?s> [
<depends-on $s <service-state <milestone system-layer> up>>
<require-service $s>
]
; Once we see that the `system-layer` milestone is ready, start processing the `services`
; directory.
;
? <service-state <milestone system-layer> up> [
<require-service <config-watcher "./services" {
config: $basic
gatekeeper: $gatekeeper
log: $log
}>>
]

View File

@ -0,0 +1,4 @@
<require-service <daemon httpd>>
<daemon httpd <one-shot "echo httpd">>

View File

@ -0,0 +1,3 @@
#!/bin/sh
make -C ~/src/syndicate-rs
~/src/syndicate-rs/target/debug/syndicate-server -c boot/

View File

@ -0,0 +1,7 @@
<require-service <daemon eudev>>
<require-service <daemon eudev-initial-scan>>
<daemon eudev <one-shot "echo eudev">>
<depends-on <daemon eudev-initial-scan> <service-state <daemon eudev> up>>
<daemon eudev-initial-scan <one-shot "echo eudev-initial-scan">>