forked from dan/liminix
fix startup race/fencepost in watch-ssh-keys
if it starts _after_ the outputs are populated, it should write the first lot of outputs without waiting for a change
This commit is contained in:
parent
091d863710
commit
146a2d9ac0
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
(fn write-changes [path old-tree new-tree]
|
(fn write-changes [path old-tree new-tree]
|
||||||
(when (not (table= old-tree new-tree))
|
(when (not (table= old-tree new-tree))
|
||||||
|
(io.stderr:write "new ssh keys\n")
|
||||||
(each [username pubkeys (pairs new-tree)]
|
(each [username pubkeys (pairs new-tree)]
|
||||||
(with-open [f (assert (io.open (.. path "/" username) :w))]
|
(with-open [f (assert (io.open (.. path "/" username) :w))]
|
||||||
;; the keys are "1" "2" "3" etc, so pairs not ipairs
|
;; the keys are "1" "2" "3" etc, so pairs not ipairs
|
||||||
@ -47,12 +48,11 @@
|
|||||||
(os.remove out-dir)
|
(os.remove out-dir)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
(fn run []
|
(fn run []
|
||||||
(let [{: out-path : watched-service : path } (parse-args arg)
|
(let [{: out-path : watched-service : path } (parse-args arg)
|
||||||
dir (.. watched-service "/.outputs")
|
dir (.. watched-service "/.outputs")
|
||||||
service (assert (svc.open dir))]
|
service (assert (svc.open dir))]
|
||||||
(accumulate [tree (or (service:output path) {})
|
(accumulate [tree {}
|
||||||
v (service:events)]
|
v (service:events)]
|
||||||
(write-changes out-path tree (or (service:output path) {})))))
|
(write-changes out-path tree (or (service:output path) {})))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user