Applications properly self-reload.

This commit is contained in:
C. Guy Yarvin 2014-06-07 19:45:00 -07:00
parent ba59c5bffc
commit ff2c010efe
6 changed files with 149 additions and 53 deletions

View File

@ -1,4 +1,4 @@
!:
::
:: ames (4a), networking
::
|= pit=vase

View File

@ -1,4 +1,4 @@
!:
::
:: clay (4c), revision control
::
|= pit=vase

View File

@ -1,13 +1,15 @@
:: :: %eyre, http servant
!: :: %eyre, http servant
!? 164
::::
|= pit=vase
=> =~
|% :: interfaces
++ chop ,[p=@ud q=@da] :: see
++ gift :: out result <-$
$% [%thou p=httr] :: raw http response
[%thus p=@ud q=(unit hiss)] :: http request/cancel
== ::
++ hasp ,[p=ship q=term] :: see %gall
++ hope (pair ,? path) :: see %gall
++ kiss :: in request ->$
$% [%born ~] :: new unix process
@ -26,19 +28,19 @@
[%flog p=[%crud p=@tas q=(list tank)]] :: to %dill
[%line p=@t] :: to %batz
[%ling ~] :: to %batz
[%shah p=hasp q=(unit hope)] :: to %gall
[%show p=hasp q=(unit hope)] :: to %gall
[%this p=? q=clip r=httq] :: to %eyre
[%thud ~] :: to %eyre
[%wait p=hasp q=@ud] :: to %gall
[%want p=sock q=path r=*] :: to %ames
[%warp p=sock q=riff] :: to %clay
== ::
++ sign :: in result $-<
$% [%boot ~] :: by %gall
$% [%boot p=@ud] :: by %gall
[%crud p=@tas q=(list tank)] :: by any
[%helo p=path q=prod] :: by %batz
[%made p=(each bead (list tank))] :: by %ford
:: [%rush p=@da q=json] :: by %gall
[%rust p=@da q=cage] :: by %gall
[%rust p=chop q=cage] :: by %gall
[%talk p=tank] :: by %batz
[%tell p=(list ,@t)] :: by %batz
[%text p=tape] :: by %batz
@ -95,6 +97,7 @@
hen=duct :: event trace
som=seam :: logical request
pez=pest :: request state
sip=(list manx) :: scripts in result
== ::
++ rote :: remote server
$: cnt=@ud :: number served
@ -229,8 +232,9 @@
^+ +>
?- -.sin
%boot
~& %eyre-boot
+>.$
?> ?=([%hova @ @ @ ~] tea)
%- goja
[(need (slaw %p i.t.tea)) i.t.t.tea (need (slaw %ud i.t.t.t.tea)) +.sin]
::
%crud
+>.$(mow [[hen %slip %d %flog sin] mow])
@ -381,13 +385,21 @@
?~ cuz +>.$
abet:work:(~(dodo ya [our ses] u.suf u.cuz) num sin)
::
++ gojo :: app result
|= [our=ship ses=hole num=@ud wen=@da cay=cage]
++ goja :: app result
|= [our=ship ses=hole num=@ud tik=@ud]
=+ suf=(~(get by own) our)
?~ suf +>.$
=+ cuz=(~(get by wup.u.suf) ses)
?~ cuz +>.$
abet:work:(~(dojo ya [our ses] u.suf u.cuz) num wen cay)
abet:work:(~(doja ya [our ses] u.suf u.cuz) num tik)
::
++ gojo :: app result
|= [our=ship ses=hole num=@ud cup=chop cay=cage]
=+ suf=(~(get by own) our)
?~ suf +>.$
=+ cuz=(~(get by wup.u.suf) ses)
?~ cuz +>.$
abet:work:(~(dojo ya [our ses] u.suf u.cuz) num cup cay)
::
++ gosh :: receive %pr response
|= [him=ship num=@ud har=httr]
@ -502,6 +514,16 @@
[%want [sor.rot him] [%q %pr %e %hork mun ~] ~]
==
::
++ hova :: app wait
|= [our=ship num=@ud ses=hole app=term tik=@ud]
%_ +>
mow
:_ mow
:^ hen %toss %g
:- [%hova (scot %p our) ses (scot %ud num) ~]
[%wait [our app] tik]
==
::
++ hove :: app peek
|= [our=ship num=@ud ses=hole app=term pax=path]
%_ +>
@ -509,7 +531,7 @@
:_ mow
:^ hen %toss %g
:- [%hove (scot %p our) ses (scot %ud num) ~]
[%shah [our app] `[%| pax]]
[%show [our app] `[%| pax]]
==
::
++ hork :: remote request
@ -900,18 +922,41 @@
?~(yov +>.$ (dove ~[%a (jone ono.cal) (jone ino.cal) jon] yov))
::
++ dojo :: app view
|= [num=@ud wen=@da cay=cage]
|= [num=@ud cup=chop cay=cage]
^+ +>
=+ pup=(~(get by q.rey) num)
?~ pup ~&([%dojo-lost ses num] +>.$)
~& [%dojo num wen]
?> ?=(%way pez.u.pup)
?> ?=(%apg -.som.u.pup)
=. q.rey
%+ ~(put by q.rey)
num
%= u.pup
sip
:_ sip.u.pup
%- dute
^- path
:~ (rsh 3 1 (scot %p our))
%gez
p.som.u.pup
(scot %ud +(p.cup))
==
==
=+ bek=`beak`[our %main [%da now]]
=+ kas=`silk`[%cast %mime bek [%cast q.som.u.pup bek [%done ~ cay]]]
+>.$(..ya (honk our num ses kas))
::
++ iota :: change response
++ doja :: app reboot
|= [num=@ud tik=@ud]
^+ +>
=+ pup=(~(get by q.rey) num)
?~ pup
~& [%doja-lost ses num tik]
+>.$
?> ?=(%way pez.u.pup)
+>.$(q.rey (~(put by q.rey) num u.pup(pez [%fin %mid /text/plain *octs])))
::
++ iota :: fun change response
|= [num=@ud rot=riot]
^+ +>
=+ pup=(~(get by q.rey) num)
@ -932,6 +977,41 @@
?> ?=(%way pez.u.pup)
$(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz)))
::
++ dute :: reload script
|= pax=path
=- =+ cal=:/("path=\"{<pax>}\"")
[-.sac [cal +.sac]]
^= sac
;script
;
; tries = 0;
; call = function() {
; xhr = new XMLHttpRequest();
; xhr.open('GET', path, true);
; xhr.addEventListener('load', function() {
; if(this.status !== 200) {
; return keep();
; }
; document.location.reload();
; });
; xhr.addEventListener('error', keep);
; xhr.addEventListener('abort', keep);
; xhr.send();
; }
; keep = function() {
; setTimeout(call,1000*tries);
; tries++;
; }
; call();
==
::
++ fape
|= [fur=(unit term) paw=path]
^- (unit seam)
?> ?=(~ fur)
?> ?=([@ @ ~] paw)
`[%ape i.paw (need (slaw %ud i.t.paw))]
::
++ fapp :: dispatch app
|= [fur=(unit term) paw=path]
^- (unit seam)
@ -1147,10 +1227,11 @@
?= $? %p :: application
%c :: console
%f :: functional
%v :: version
%v :: functional version
%l :: local login
%m :: remote login
%n :: now
%z :: app version
==
tri
::
@ -1170,6 +1251,7 @@
%c (flub paw ~)
%l (fool r.pul)
%p (fapp p.q.pul paw)
%z (fape p.q.pul paw)
==
::
%p
@ -1199,7 +1281,6 @@
++ inch :: function built
|= [num=@ud mez=(each bead (list tank))]
^+ +>
~& [%inch num -.mez]
=+ pup=(~(get by q.rey) num)
?~ pup
~& [%inch-lost ses num mez]
@ -1221,6 +1302,7 @@
hen
*seam
`pest`[%raw pul moh]
~
==
==
::
@ -1259,9 +1341,11 @@
%way [[~ pip] +>.$]
%new
?- -.som.pip
%ape !!
%ape
:- [~ pip(pez %way)]
+>.$(..ya (hova our num ses p.som.pip q.som.pip))
::
%apg :: simple get
~& [%wink-apg p.som.pip r.som.pip]
:- [~ pip(pez %way)]
+>.$(..ya (hove our num ses p.som.pip r.som.pip))
::
@ -1608,9 +1692,10 @@
[~ pip(pez [%fin %wan 'Hello, world' ~])]
::
[%fud *]
=+ ^= mog
?: ?=(%fun -.som.pip) r.som.pip
~
=+ ^= mog ^- (list manx)
?: ?=(%fun -.som.pip)
(weld r.som.pip sip.pip)
sip.pip
:_ +>.$
:- ~
%= pip

View File

@ -303,7 +303,6 @@
::
++ expo :: return gift
|= gef=gift
~& [%expo -.gef]
%_(+> mow :_(mow [hen %give gef]))
::
++ fade :: compile
@ -537,7 +536,7 @@
++ make :: reduce silk
|= [cof=cafe kas=silk]
^- (bolt cage)
~& [%ford-make -.kas]
:: ~& [%ford-make -.kas]
?- -.kas
^
%. [cof p.kas q.kas]

View File

@ -12,7 +12,7 @@
++ chop ,[p=@ud q=@da] :: revision/date
++ gift :: out result <-$
$% [%back p=?] :: %mess ack good/bad
[%boot p=@ud q=@da] :: response to %wait
[%boot p=@ud] :: response to %wait
[%crud p=@tas q=(list tank)] :: error
[%done ~] :: reset duct
[%rasp p=cage] :: reaction message
@ -20,6 +20,7 @@
[%rust p=chop q=cage] :: full update
[%meta p=vase] :: meta-gift
== ::
++ hasp ,[p=ship q=term] :: app identity
++ hope (pair ,? path) :: view/subscribe
++ kiss :: in request ->$
$% [%show p=hasp q=(unit hope)] :: urb subscribe/cancel
@ -27,7 +28,7 @@
[%mess p=hasp q=cage] :: message
[%nuke p=hasp] :: reset this duct
[%show p=hasp q=(unit hope)] :: web subscribe/cancel
[%wait p=@ud] :: await revision
[%wait p=hasp q=@ud] :: await tick
== ::
++ knob :: pending action
$% [%boot ~] :: boot/reboot
@ -36,6 +37,7 @@
[%nuke ~] :: destroy duct
[%show p=(unit hope)] :: subscribe/cancel
[%take p=path q=vase] :: user result
[%wait p=@ud] :: await tick
== ::
++ mast :: apps by ship
$: bum=(map ,@ta seat) :: apps by name
@ -58,7 +60,7 @@
vey=(qeu toil) :: pending projects
tik=@ud :: build number
orm=(unit ,@da) :: build date
med=(map duct ,@ud) :: waiters
med=(map ,@ud (list duct)) :: waiters
ped=(set (pair ship desk)) :: dependencies
zam=scar :: opaque ducts
== ::
@ -152,7 +154,7 @@
%mess [law p.q.hic %mess q.q.hic]
%show [law p.q.hic %show q.q.hic]
%nuke [law p.q.hic %nuke ~]
%wait !!
%wait [law p.q.hic %wait q.q.hic]
==
abet:work:(quem:(boar:(goat hap) hen law) kon)
::
@ -353,16 +355,29 @@
^- silk
[%done ~ cay]
::
++ deal :: advance tick
^+ .
=. tik.sat +(tik.sat)
=+ dyq=(dear tik.sat)
|- ^+ +>.$
?~ dyq +>.$(med.sat (~(del by med.sat) tik.sat))
=. +>.$ $(dyq t.dyq)
(give(hen i.dyq) %boot tik.sat)
::
++ dear :: waiters
|= tik=@ud
^- (list duct)
=+ dyq=(~(get by med.sat) tik.sat)
?~(dyq ~ u.dyq)
::
++ drug :: set dependencies
|= pen=(set (pair ship desk))
~& [%drug-want ped.sat]
^+ +>
=+ ^= new ^- (list move)
%+ turn
%+ skip (~(tap in pen) ~)
|=(a=(pair ship desk) (~(has in ped.sat) a))
|= a=(pair ship desk)
~& [%drug-gain a]
:- hen
:^ %toss %c (away %s %drug ~)
[%warp [our p.a] q.a ~ %| [%da now] [%da (add now ~d1000)]]
@ -371,7 +386,6 @@
%+ skip (~(tap in ped.sat) ~)
|=(a=(pair ship desk) (~(has in pen) a))
|= a=(pair ship desk)
~& [%drug-stop a]
:- hen
:^ %toss %c (away %s %drug ~)
[%warp [our p.a] q.a ~]
@ -440,14 +454,13 @@
?> ?=([~ * %boot ~] qic.sat)
?> ?=(%made -.q.hin)
?- -.p.q.hin
& ~& %boot-good
(drum:(morn:gone q.q.p.p.q.hin) p.p.p.q.hin)
| ~& %boot-lost
& :: ~& %boot-good
deal:(drum:(morn:gone q.q.p.p.q.hin) p.p.p.q.hin)
| :: ~& %boot-lost
(mort p.p.q.hin)
==
::
%drug
~& %more-drug
?> ?=(%writ -.q.hin)
?~ p.q.hin +>.$
+>.$(vey.sat (~(put to vey.sat) hen %boot ~))
@ -455,11 +468,11 @@
%step
?> ?=(%made -.q.hin)
?- -.p.q.hin
& ~& %step-good
%- obey:(morn:gone (slot 3 q.q.p.p.q.hin))
& :: ~& %step-good
%- obey:(morn:gone (slot 3 q.q.p.p.q.hin))
(slot 2 q.q.p.p.q.hin)
| ~& %step-fail
(give %crud %made p.p.q.hin)
| :: ~& %step-fail
(give %crud %made p.p.q.hin)
==
==
::
@ -480,7 +493,12 @@
::
++ quem :: queue action
|= kon=knob :: content
%_(+> vey.sat (~(put to vey.sat) hen kon))
^+ +>
?. ?=(%wait -.kon)
%_(+> vey.sat (~(put to vey.sat) hen kon))
?: (lte p.kon tik.sat)
(give %boot p.kon)
%_(+>.$ med.sat (~(put by med.sat) p.kon [hen (dear p.kon)]))
::
++ said
|= vud=vase
@ -504,9 +522,9 @@
::
[%rust *]
:^ %rust
((hard chop) +<.q.vig)
((hard lode) +>-.q.vig)
(slot 15 vig)
[tik.sat now]
((hard lode) +<.q.vig)
(slot 7 vig)
==
::
++ sump
@ -532,7 +550,6 @@
::
++ work :: eat queue
^+ .
~& %gall-work
?: |(?=(^ qic.sat) =(~ vey.sat)) . :: nothing to do
=^ yev vey.sat [p q]:~(get to vey.sat)
work:(yawn:(bing p.yev) q.yev)
@ -540,11 +557,10 @@
++ yawn :: start event
|= kon=knob
^+ +>
~& [%gall-yawn -.kon]
:: ~& [%gall-yawn -.kon]
=. qic.sat `[hen kon]
?- -.kon
%boot
~& %yawn-boot
=. orm.sat `now
%+ ford %boot
^- silk
@ -554,7 +570,6 @@
[nile (harm %save (conf u.huv.sat))]
::
%crud
~& %yawn-crud
?~ huv.sat
~& [%crud-none our app]
gone:(give %crud p.kon q.kon)
@ -562,7 +577,6 @@
!>([ost use p.kon])
::
%mess
~& %yawn-mess
?~ huv.sat
~& [%mess-none our app]
gone:(give %back |)
@ -570,14 +584,12 @@
:(slop [[%atom %ud] ost] !>((ride use say)) q.p.kon)
::
%nuke
~& %yawn-mess
?~ huv.sat
~& [%nuke-none our app]
gone
(game [%step %punk] u.huv.sat !>([ost ~]))
::
%show
~& %yawn-show
?~ huv.sat
~& [%show-none our app]
gone:(give %done ~)
@ -585,10 +597,11 @@
!>([ost use | p.kon])
::
%take
~& %yawn-take
?> ?=(^ huv.sat)
%^ game [%step %peck] u.huv.sat
:(slop [[%atom %ud] ost] !>((ride use say)) !>(p.kon) q.kon)
::
%wait !! :: handled above
==
--
--

View File

@ -2221,7 +2221,6 @@
++ gram ,@uw :: physical datagram
++ hand ,@uvH :: hash of code
++ hart ,[p=? q=(unit ,@ud) r=host] :: http sec/port/host
++ hasp ,[p=ship q=term] :: app identity
++ hate ,[p=purl q=@p r=moth] :: semi-cooked request
++ heir ,[p=@ud q=mess r=(unit love)] :: status/headers/data
++ hiss ,[p=purl q=moth] :: outbound request