From 38d6d0f4d47b14a4c2cc96d3174b5ed873cddb9d Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Mon, 19 Jul 2021 16:58:18 +0300 Subject: [PATCH] gall,kiln: clean up agent stopping, starting, linking --- pkg/arvo/lib/hood/kiln.hoon | 71 +++++++++++++++++++++---------------- pkg/arvo/sys/vane/gall.hoon | 11 +++--- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index 944bde7d78..632818c89a 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -229,6 +229,22 @@ |= [step=@tas =task:clay] ^- card:agent:gall [%pass (make-wire step) %arvo %c task] + ++ start-dude + |= =dude + ^- (list card:agent:gall) + :- [%pass /kiln/vats/[loc]/jolt/[dude] %arvo %g %jolt loc dude] + ?. (is-fish loc dude) + ~ + =/ =cage [%drum-link !>([our dude])] + [%pass /kiln/link/[dude] %agent [our %hood] %poke cage]~ + ++ stop-dude + |= =dude + ^- (list card:agent:gall) + :- [%pass /kiln/vats/[loc]/uninstall %arvo %g %idle dude] + ?. (is-fish loc dude) + ~ + =/ =cage [%drum-unlink !>([our dude])] + [%pass /kiln/link/[dude] %agent [our %hood] %poke cage]~ -- :: +uninstall: stop tracking apps on desk, and suspend apps :: @@ -240,12 +256,7 @@ kiln =. vats (abed lac) ~> %slog.0^leaf/"kiln: uninstalling {here}" - =. vats - %- emil - %+ turn (get-apps-have lac) - |= =dude - [%pass /kiln/vats/[lac]/uninstall %arvo %g %idle dude] - :: + =. vats (update-running-apps liv=~ ded=(get-apps-live lac)) kiln(ark (~(del by ark) lac)) :: +install: set up desk sync to .lac to install all apps from [her rem] :: @@ -378,20 +389,8 @@ %- (slog leaf/- p.p.syn) vats =. vats - =/ dif (get-apps-diff loc rein.rak) ~> %slog.0^leaf/"kiln: merge into {here} succeeded" - ~> %slog.0^leaf/"kiln: starting {}" - ~> %slog.0^leaf/"kiln: stopping {}" - %- emil - %+ weld - ^- (list card:agent:gall) - %+ turn liv.dif - |= =dude - [%pass /kiln/vats/[loc]/jolt/[dude] %arvo %g %jolt loc dude] - ^- (list card:agent:gall) - %+ turn ded.dif - |= =dude - [%pass /kiln/vats/[loc]/idle/[dude] %arvo %g %idle dude] + (update-running-apps (get-apps-diff loc rein.rak)) ?. =(%base loc) vats =. kiln (bump (sy %base %kids ~)) @@ -421,15 +420,19 @@ ^+ vats =/ onto ?>(?=([%gall %onto *] syn) p.syn) ?- -.onto - %& ~_ leaf/"kiln: %onto bad wire {}" - ?> ?=([@ @ @ ~] wire) - =+ ;;([=desk =dude] [i i.t.t]:wire) - ?. (is-fish dude desk) - vats - =/ =cage [%drum-link !>([our dude])] - (emit %pass /kiln/link/[dude] %agent [our %hood] %poke cage) - %| (mean p.onto) :: TODO: kill arvo event on failure + %& vats + %| (mean p.onto) == + :: + ++ update-running-apps + |= [liv=(list dude) ded=(list dude)] + ^+ vats + ~> %slog.0^leaf/"kiln: starting {}" + ~> %slog.0^leaf/"kiln: stopping {}" + %- emil + %+ weld + `(list card:agent:gall)`(zing (turn liv start-dude:pass)) + `(list card:agent:gall)`(zing (turn ded stop-dude:pass)) -- :: +get-ankh: extract $ankh from clay %v response $rant :: @@ -441,7 +444,7 @@ :: +is-fish: should dill link .dude? :: ++ is-fish - |= [=dude =desk] + |= [=desk =dude] ^- ? =+ .^(=bill cx+/(scot %p our)/[desk]/(scot %da now)/desk/bill) .?((find ~[dude] (read-fish bill))) @@ -451,17 +454,23 @@ |= [=desk =rein] ^- [liv=(list dude) ded=(list dude)] =/ wan (sy (get-apps-want desk rein)) - =/ hav (sy (get-apps-have desk)) + =/ hav (sy (get-apps-live desk)) =/ liv ~(tap in (~(dif in wan) hav)) =/ ded ~(tap in (~(dif in hav) wan)) [liv ded] +:: +++ get-apps-live + |= =desk + ^- (list dude) + %+ murn (get-apps-have desk) + |=([=dude live=?] ?.(live ~ `dude)) :: +get-apps-have: find which apps Gall is running on a desk :: ++ get-apps-have |= =desk - ^- (list dude) + ^- (list [=dude live=?]) %~ tap in - .^((set dude) ge+/(scot %p our)/[desk]/(scot %da now)) + .^((set [=dude live=?]) ge+/(scot %p our)/[desk]/(scot %da now)) :: +get-apps-want: find which apps should be running on a desk :: ++ get-apps-want diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 23342ec65d..2c1f8f21d4 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1013,7 +1013,10 @@ moves moves == :: - ++ ap-idle ap-core(agent.yoke |+on-save:ap-agent-core) + ++ ap-idle + ?: ?=(%| -.agent.yoke) ap-core + ap-core(agent.yoke |+on-save:ap-agent-core) + :: ++ ap-nuke ^+ ap-core =/ out=(list [[=wire =ship =term] ? =path]) @@ -1757,13 +1760,13 @@ =(our ship) == :+ ~ ~ - :- %apps !> ^- (set dude) + :- %apps !> ^- (set [=dude live=?]) =* syd=desk dap %+ roll ~(tap by yokes.state) - |= [[=dude =yoke] acc=(set dude)] + |= [[=dude =yoke] acc=(set [=dude live=?])] ?. =(syd q.beak.yoke) acc - (~(put in acc) dude) + (~(put in acc) [dude -.agent.yoke]) :: ?. =(our ship) ~