summaryrefslogtreecommitdiff
path: root/appl/demo/cpupool
diff options
context:
space:
mode:
Diffstat (limited to 'appl/demo/cpupool')
-rw-r--r--appl/demo/cpupool/mkfile26
-rw-r--r--appl/demo/cpupool/regpoll.b63
-rw-r--r--appl/demo/cpupool/regpoll.disbin0 -> 904 bytes
-rw-r--r--appl/demo/cpupool/regpoll.sbl262
-rwxr-xr-xappl/demo/cpupool/runrstyx.sh50
5 files changed, 401 insertions, 0 deletions
diff --git a/appl/demo/cpupool/mkfile b/appl/demo/cpupool/mkfile
new file mode 100644
index 00000000..4531899b
--- /dev/null
+++ b/appl/demo/cpupool/mkfile
@@ -0,0 +1,26 @@
+<../../../mkconfig
+
+TARG=\
+ regpoll.dis\
+
+SHTARG=\
+ runrstyx.sh\
+
+MODULES=\
+
+SYSMODULES= \
+ draw.m\
+ registries.m\
+ sys.m\
+
+DISBIN=$ROOT/dis/demo/cpupool
+
+<$ROOT/mkfiles/mkdis
+
+SHFILES=${SHTARG:%.sh=$DISBIN/%}
+install:V: $SHFILES
+%.install:V: $DISBIN/%
+%.installall:V: $DISBIN/%
+
+$DISBIN/%: %.sh
+ cp $stem.sh $target && chmod a+rx $target
diff --git a/appl/demo/cpupool/regpoll.b b/appl/demo/cpupool/regpoll.b
new file mode 100644
index 00000000..52ea3d1f
--- /dev/null
+++ b/appl/demo/cpupool/regpoll.b
@@ -0,0 +1,63 @@
+implement RegPoll;
+
+include "sys.m";
+ sys : Sys;
+include "draw.m";
+include "registries.m";
+ registries: Registries;
+ Attributes, Service: import registries;
+
+RegPoll: module {
+ init: fn(nil: ref Draw->Context, argv: list of string);
+};
+
+init(nil: ref Draw->Context, argv: list of string)
+{
+ sys = load Sys Sys->PATH;
+ if (sys == nil)
+ badmod(Sys->PATH);
+ registries = load Registries Registries->PATH;
+ if (registries == nil)
+ badmod(Registries->PATH);
+ registries->init();
+
+ if (len argv != 3)
+ usage();
+
+ regaddr := hd tl argv;
+ action := hd tl tl argv;
+ if (action != "up" && action != "down")
+ usage();
+
+ sys->pctl(sys->FORKNS, nil);
+ sys->unmount(nil, "/mnt/registry");
+ svc := ref Service(hd tl argv, Attributes.new(("auth", "none") :: nil));
+ for (;;) {
+ a := svc.attach(nil, nil);
+ if (a != nil && sys->mount(a.fd, nil, "/mnt/registry", Sys->MREPL, nil) != -1) {
+ if (action == "up")
+ return;
+ else
+ break;
+ }
+ sys->sleep(30000);
+ }
+ for (;;) {
+ fd := sys->open("/mnt/registry/new", sys->OREAD);
+ sys->sleep(30000);
+ if (fd == nil)
+ return;
+ }
+}
+
+badmod(path: string)
+{
+ sys->print("RegPoll: failed to load: %s\n",path);
+ exit;
+}
+
+usage()
+{
+ sys->print("usage: regpoll regaddr up | down\n");
+ raise "fail:usage";
+} \ No newline at end of file
diff --git a/appl/demo/cpupool/regpoll.dis b/appl/demo/cpupool/regpoll.dis
new file mode 100644
index 00000000..d64a7a55
--- /dev/null
+++ b/appl/demo/cpupool/regpoll.dis
Binary files differ
diff --git a/appl/demo/cpupool/regpoll.sbl b/appl/demo/cpupool/regpoll.sbl
new file mode 100644
index 00000000..613e78a8
--- /dev/null
+++ b/appl/demo/cpupool/regpoll.sbl
@@ -0,0 +1,262 @@
+limbo .sbl 2.1
+RegPoll
+4
+regpoll.b
+sys.m
+draw.m
+registries.m
+104
+16.1,25 0
+17.5,15 1
+18.2,19 2
+9,18 2
+2,19 2
+19.1,46 3
+20.5,22 4
+21.2,26 5
+9,25 5
+2,26 5
+22.1,19 6
+1,19 6
+24.5,13 7
+5,18 7
+25.2,9 8
+2,9 8
+27.15,22 9
+1,22 9
+1,22 10
+28.17,24 11
+14,24 11
+1,24 11
+1,24 12
+29.5,19 13
+23,39 13
+30.2,9 14
+2,9 14
+32.1,28 15
+11,22 15
+24,27 15
+1,28 15
+1,28 15
+33.1,35 16
+14,17 16
+19,34 16
+1,35 16
+1,35 16
+34.1,72 17
+23,30 17
+20,30 17
+20,30 18
+32,71 17
+48,54 17
+56,62 17
+67,70 17
+47,70 17
+47,70 17
+47,70 19
+47,70 20
+47,70 21
+32,71 17
+32,71 17
+1,72 17
+1,72 22
+36.2,27 23
+7,10 23
+18,21 23
+23,26 23
+2,27 23
+2,27 23
+37.6,14 24
+18,73 24
+29,33 24
+35,38 24
+40,55 24
+57,67 24
+69,72 24
+18,73 24
+18,73 24
+18,79 24
+38.7,21 25
+39.4,10 26
+4,10 27
+41.4,9 28
+43.2,19 29
+13,18 29
+2,19 29
+2,19 29
+2,19 30
+2,19 30
+46.2,50 31
+18,37 31
+39,49 31
+2,50 31
+2,50 31
+47.2,19 32
+13,18 32
+2,19 32
+2,19 32
+48.6,15 33
+49.3,9 34
+3,9 35
+3,9 35
+55.1,49 36
+12,43 36
+44,48 36
+1,49 36
+1,49 36
+56.1,5 37
+61.1,49 38
+12,48 38
+1,49 38
+1,49 38
+62.1,19 39
+15
+aSys->Dir 1:26.1,39.2 64
+11
+0:name:28.2,6 s
+4:uid:29.2,5 s
+8:gid:30.2,5 s
+12:muid:31.2,6 s
+16:qid:32.2,5 @1
+
+32:mode:33.2,6 i
+36:atime:34.2,7 i
+40:mtime:35.2,7 i
+48:length:36.2,8 B
+56:dtype:37.2,7 i
+60:dev:38.2,5 i
+aSys->Qid 11.1,16.2 16
+3
+0:path:13.2,6 B
+8:vers:14.2,6 i
+12:qtype:15.2,7 i
+aDraw->Chans 2:70.1,82.2 4
+1
+0:desc:72.2,6 i
+aDraw->Context 274.1,279.2 12
+3
+0:display:276.2,9 R@4
+
+4:screen:277.2,8 R@8
+
+8:wm:278.2,4 Ct8.2
+0:t0:15,21 s
+4:t1:15,21 Ct8.2
+0:t0:32,38 s
+4:t1:32,38 R@9
+
+
+
+aDraw->Display 201.1,230.2 20
+5
+0:image:203.2,7 R@5
+
+4:white:204.2,7 R@5
+
+8:black:205.2,7 R@5
+
+12:opaque:206.2,8 R@5
+
+16:transparent:207.2,13 R@5
+
+aDraw->Image 142.1,198.2 56
+8
+0:r:146.2,3 @6
+
+16:clipr:147.2,7 @6
+
+32:depth:148.2,7 i
+36:chans:149.2,7 @2
+
+40:repl:150.2,6 i
+44:display:151.2,9 R@4
+
+48:screen:152.2,8 R@8
+
+52:iname:153.2,7 s
+aDraw->Rect 116.1,139.2 16
+2
+0:min:118.2,5 @7
+
+8:max:119.2,5 @7
+
+aDraw->Point 99.1,113.2 8
+2
+0:x:101.2,3 i
+4:y:102.2,3 i
+aDraw->Screen 249.1,263.2 16
+4
+0:id:251.2,4 i
+4:image:252.2,7 R@5
+
+8:fill:253.2,6 R@5
+
+12:display:254.2,9 R@4
+
+aDraw->Wmcontext 282.1,291.2 28
+7
+0:kbd:284.2,5 Ci
+4:ptr:285.2,5 CR@10
+
+8:ctl:286.2,5 Cs
+12:wctl:287.2,6 Cs
+16:images:288.2,8 CR@5
+
+20:connfd:289.2,8 R@11
+
+24:ctxt:290.2,6 R@3
+
+aDraw->Pointer 266.1,271.2 16
+3
+0:buttons:268.2,9 i
+4:xy:269.2,4 @7
+
+12:msec:270.2,6 i
+aSys->FD 1:45.1,48.2 4
+1
+0:fd:47.2,4 i
+aRegistries->Service 3:20.1,25.2 8
+2
+0:addr:21.2,6 s
+4:attrs:22.2,7 R@13
+
+aRegistries->Attributes 5.1,11.2 4
+1
+0:attrs:6.2,7 Lt8.2
+0:t0:18,24 s
+4:t1:18,24 s
+
+aRegistries->Attached 13.1,18.2 16
+4
+0:fd:14.2,4 R@11
+
+4:signerpkhash:15.2,14 s
+8:localuser:16.2,11 s
+12:remoteuser:17.2,12 s
+3
+0:init
+1
+36:argv:0:14.29,33 Ls
+5
+40:action:28.1,7 s
+44:a:36.2,3 R@14
+
+48:fd:46.2,4 R@11
+
+52:svc:34.1,4 R@12
+
+72:regaddr:27.1,8 s
+n93:badmod
+1
+32:path:53.7,11 s
+0
+n99:usage
+0
+0
+n2
+40:registries:7.1,11 mRegistries
+3:1.0,44.1 0
+
+44:sys:0:4.1,4 mSys
+1:0,160.1 0
+
diff --git a/appl/demo/cpupool/runrstyx.sh b/appl/demo/cpupool/runrstyx.sh
new file mode 100755
index 00000000..21a548a3
--- /dev/null
+++ b/appl/demo/cpupool/runrstyx.sh
@@ -0,0 +1,50 @@
+#!/dis/sh
+fn bindfs {
+ # this may be useful as a general purpose cmd
+ (mntpt dirs)=$*
+ memfs $mntpt
+ for d in $dirs {
+ parts=${split / $d}
+ fpath=''
+ for p in $parts {
+ fpath=$fpath^/^$p
+ if {! ftest -e $mntpt^$fpath} {
+ if {ftest -d $fpath} {
+ mkdir $mntpt^$fpath
+ } {
+ if {! ftest -e $fpath} {
+ echo $fpath does not exist >[1=2]
+ raise 'fail:errors'
+ }
+ }
+ }
+ }
+ if {! ftest -d $d} {
+ touch $mntpt/$d
+ }
+ bind $d $mntpt^$d
+ }
+}
+
+fn x {
+ echo tcp!^$2
+}
+
+bindfs /tmp /dis /n/client /dev /prog
+listen -A `{x `{ndb/csquery tcp!^`{cat /dev/sysname}^!rstyx}} {
+ @{
+ load std
+ pctl forkns nodevs
+ bind /tmp /
+ runas rstyx {auxi/rstyxd}
+ }&
+ }
+
+while {} {
+ demo/cpupool/regpoll tcp!200.1.1.104!6676 up
+ echo Registering Rstyx service
+ mount -A 'tcp!200.1.1.104!6676' /mnt/registry
+ echo `{x `{ndb/csquery tcp!^`{cat /dev/sysname}^!rstyx}} proto styx auth none persist 1 resource '''Rstyx resource''' name `{cat /dev/sysname} > /mnt/registry/new
+ demo/cpupool/regpoll tcp!200.1.1.104!6676 down
+ echo Registry gone down
+} \ No newline at end of file