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