Compare commits
4 Commits
12275f6896
...
a139a262c1
Author | SHA1 | Date | |
---|---|---|---|
|
a139a262c1 | ||
6a5fed83dd | |||
bcf5ab24e8 | |||
32bf80c6fa |
@ -115,6 +115,7 @@ in {
|
|||||||
# vendor OS, or even to derisk Liminix updates on that device
|
# vendor OS, or even to derisk Liminix updates on that device
|
||||||
schnapps = callPackage ./schnapps { };
|
schnapps = callPackage ./schnapps { };
|
||||||
|
|
||||||
|
seedrng = callPackage ./seedrng {};
|
||||||
serviceFns = callPackage ./service-fns { };
|
serviceFns = callPackage ./service-fns { };
|
||||||
swconfig = callPackage ./swconfig { };
|
swconfig = callPackage ./swconfig { };
|
||||||
systemconfig = callPackage ./systemconfig { };
|
systemconfig = callPackage ./systemconfig { };
|
||||||
|
@ -131,6 +131,7 @@
|
|||||||
(fn unix-socket [name]
|
(fn unix-socket [name]
|
||||||
(let [addr (string.pack "=Hz" AF_LOCAL name)
|
(let [addr (string.pack "=Hz" AF_LOCAL name)
|
||||||
fd (check-errno (ll.socket AF_LOCAL SOCK_STREAM 0))]
|
fd (check-errno (ll.socket AF_LOCAL SOCK_STREAM 0))]
|
||||||
|
(os.remove name)
|
||||||
(check-errno (ll.bind fd addr))
|
(check-errno (ll.bind fd addr))
|
||||||
(check-errno (ll.listen fd 32))
|
(check-errno (ll.listen fd 32))
|
||||||
fd))
|
fd))
|
||||||
|
@ -4,19 +4,25 @@
|
|||||||
(local { : utime } (require :lualinux))
|
(local { : utime } (require :lualinux))
|
||||||
|
|
||||||
(fn download [url dest]
|
(fn download [url dest]
|
||||||
(match (http.fetch url)
|
(let [state (.. dest "/state")
|
||||||
(nil code str)
|
previously (ll.lstat state 12)]
|
||||||
(assert nil (.. "error " code ": " str))
|
(match (http.fetch url "i" previously)
|
||||||
|
(nil 10 _) ; not modified
|
||||||
|
(print (.. url " not modified, already up to date"))
|
||||||
|
|
||||||
(body { : last-modified })
|
(nil code str)
|
||||||
(let [service (svc.open dest)
|
(assert nil (.. "error " code ": " str))
|
||||||
lock (.. dest "/.lock")
|
|
||||||
state (.. dest "/state")]
|
(body { : last-modified })
|
||||||
(with-open [fout (io.open lock :w)] (fout:write ""))
|
(let [service (svc.open dest)
|
||||||
(service:output "." (json.decode body))
|
lock (.. dest "/.lock")]
|
||||||
(with-open [fout (io.open state :w)] (fout:write "ok"))
|
(with-open [fout (io.open lock :w)] (fout:write ""))
|
||||||
(os.remove lock)
|
(service:output "." (json.decode body))
|
||||||
(utime dest last-modified))))
|
(with-open [fout (io.open state :w)] (fout:write "ok"))
|
||||||
|
(utime state last-modified)
|
||||||
|
(os.remove lock))
|
||||||
|
|
||||||
|
)))
|
||||||
|
|
||||||
(fn run [] (download (. arg 1) (. arg 2)))
|
(fn run [] (download (. arg 1) (. arg 2)))
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
(local { : system : assoc : split : table= : dig } (require :anoia))
|
(local { : %% : system : assoc : split : table= : dig } (require :anoia))
|
||||||
(local svc (require :anoia.svc))
|
(local svc (require :anoia.svc))
|
||||||
(local { : view } (require :fennel))
|
(local { : view } (require :fennel))
|
||||||
(local { : kill } (require :lualinux))
|
(local { : kill } (require :lualinux))
|
||||||
@ -27,8 +27,6 @@
|
|||||||
_ path (ipairs paths)]
|
_ path (ipairs paths)]
|
||||||
(or changed? (not (table= (dig old-tree path) (dig new-tree path))))))
|
(or changed? (not (table= (dig old-tree path) (dig new-tree path))))))
|
||||||
|
|
||||||
(fn %% [fmt ...] (string.format fmt ...))
|
|
||||||
|
|
||||||
(fn do-action [action service]
|
(fn do-action [action service]
|
||||||
(case action
|
(case action
|
||||||
:restart (system (%% "s6-svc -r /run/service/%s" service))
|
:restart (system (%% "s6-svc -r /run/service/%s" service))
|
||||||
@ -42,9 +40,8 @@
|
|||||||
: watched-service
|
: watched-service
|
||||||
: paths } (parse-args arg)
|
: paths } (parse-args arg)
|
||||||
dir (.. watched-service "/.outputs")
|
dir (.. watched-service "/.outputs")
|
||||||
_ (print :service-dir dir)
|
|
||||||
service (assert (svc.open dir))]
|
service (assert (svc.open dir))]
|
||||||
(print "watching " watched-service)
|
(print (%% "watching %q" watched-service))
|
||||||
(accumulate [tree (service:output ".")
|
(accumulate [tree (service:output ".")
|
||||||
v (service:events)]
|
v (service:events)]
|
||||||
(let [new-tree (service:output ".")]
|
(let [new-tree (service:output ".")]
|
||||||
|
Loading…
Reference in New Issue
Block a user