ref: 9f8d967bc8c377d0a705d70915509274530b2a2e
parent: 37d860be30f79410ba695904f24df9b34d3f2a10
author: moody <moody@nightowl>
date: Wed Feb 4 20:45:57 EST 2026
Build index.html statically every night instead of on demand We're seeing a slight uptick in traffic, and we ran out of procs once. I have doubts about the index.html generation being the culprit, but this is fairly low hanging fruit to reduce load.
--- /dev/null
+++ b/bin/mkpage.rc
@@ -1,0 +1,77 @@
+#!/bin/rc
+
+cat <<.
+<!DOCTYPE html>
+<html>
+
+ <head>
+ <style type="text/css">
+ body{+ padding: 3em;
+ margin: auto;
+ min-width: min(95vw, 50em);
+ width: min-content;
+ font-family: sans-serif;
+ tab-space: 8;
+ }
+ h1{+ font-size: 1.5em;
+ color: #4c4c99;
+ }
+ h2{+ font-size: 1.3em;
+ color: #4c4c99;
+ }
+ h3{+ font-size: 1em;
+ color: #4c4c99;
+ }
+ </style>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <title>iso</title>
+ </head>
+.
+
+rev=`{cat /usr/build/www/9front/latest}+echo '<h1>9front builds</h1>'
+
+echo '<h2>Nightly ISO</h2>'
+for(i in /usr/build/www/9front/*^$rev^*.gz){+ i=`{basename $i}+ echo '<a href="/9front/'^$i^'">'^$i^'</a><br>'
+}
+
+echo '<h2>Nightly Drawterm Binaries</h2>'
+for(i in `{ls /usr/build/www/drawterm/*.zip}){+ i=`{basename $i}+ echo '<a href="/drawterm/'^$i^'">'^$i^'</a><br>'
+}
+
+echo '<h2>Source</h2>'
+echo '<a href="https://shithub.us/moody/iso/HEAD/info.html">On shithub</a>'
+
+echo '<h2>Logs</h2>'
+
+{+ for(i in `{ls /usr/build/www/9front/*.status}){+ basename $i | sed 's/.status//g'
+ }
+} | sort -nr | {+ while(i=`{read}){+ cat /usr/build/www/9front/$i.status | {+ res=`{read}+ commit=`{read}+ }
+ echo '<a>['^$res^']</a>'
+ if(test $i -gt 11310)
+ repo='https://git.9front.org/plan9front/9front/'
+ if not
+ repo='https://git.9front.org/plan9front/plan9front/'
+ echo '<a href="'^$repo^$commit^'/commit.html">'^$commit^'</a>'
+ echo '<a href="/9front/9front-'^$i^'.log">Build Logs</a>'
+ echo $i^'<br>'
+ }
+}
+
+echo '</html>'
--- a/bin/nightlyiso.rc
+++ b/bin/nightlyiso.rc
@@ -32,6 +32,8 @@
echo $head >>$res
echo $head >prev
+mkpage.rc >$home/www/index.html
+
#garbage collection
latest=`{cat $home/www/9front/latest} for(i in `{ls $home/www/9front | grep -v $latest | grep '\.(iso|gz|img|qcow2)$'})--- a/namespace.httpd
+++ b/namespace.httpd
@@ -1,2 +1,1 @@
-bind -a /usr/build/www /usr/www
-bind -a /n/magic /usr/www
+bind /usr/build/www /usr/www
--- a/service/tcp443
+++ b/service/tcp443
@@ -1,4 +1,3 @@
#!/bin/rc
. /cfg/$sysname/env
-execfs -m /n/magic /cfg/$sysname/src/execfs/builds/rules
exec tlssrv -c /sys/lib/tls/acmed/$domain.crt -r`{cat $3/remote} /bin/tcp80 >>[2]/sys/log/www--- a/service/tcp80
+++ b/service/tcp80
@@ -1,3 +1,2 @@
#!/bin/rc
-execfs -m /n/magic /cfg/$sysname/src/execfs/builds/rules
exec tcp80 >>[2]/sys/log/www
--- a/src/execfs/builds/footer
+++ /dev/null
@@ -1,1 +1,0 @@
-</html>
--- a/src/execfs/builds/header
+++ /dev/null
@@ -1,30 +1,0 @@
-<!DOCTYPE html>
-<html>
-
- <head>
- <style type="text/css">
- body{- padding: 3em;
- margin: auto;
- min-width: min(95vw, 50em);
- width: min-content;
- font-family: sans-serif;
- tab-space: 8;
- }
- h1{- font-size: 1.5em;
- color: #4c4c99;
- }
- h2{- font-size: 1.3em;
- color: #4c4c99;
- }
- h3{- font-size: 1em;
- color: #4c4c99;
- }
- </style>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title>iso</title>
- </head>
--- a/src/execfs/builds/index.rc
+++ /dev/null
@@ -1,47 +1,0 @@
-#!/bin/rc
-
-root=/cfg/$sysname/src/execfs/builds
-
-cat $root/header
-rev=`{cat /usr/build/www/9front/latest}-echo '<h1>9front builds</h1>'
-
-echo '<h2>Nightly ISO</h2>'
-for(i in /usr/build/www/9front/*^$rev^*.gz){- i=`{basename $i}- echo '<a href="/9front/'^$i^'">'^$i^'</a><br>'
-}
-
-echo '<h2>Nightly Drawterm Binaries</h2>'
-for(i in `{ls /usr/build/www/drawterm/*.zip}){- i=`{basename $i}- echo '<a href="/drawterm/'^$i^'">'^$i^'</a><br>'
-}
-
-echo '<h2>Source</h2>'
-echo '<a href="https://shithub.us/moody/iso/HEAD/info.html">On shithub</a>'
-
-echo '<h2>Logs</h2>'
-
-{- for(i in `{ls /usr/build/www/9front/*.status}){- basename $i | sed 's/.status//g'
- }
-} | sort -nr | {- while(i=`{read}){- cat /usr/build/www/9front/$i.status | {- res=`{read}- commit=`{read}- }
- echo '<a>['^$res^']</a>'
- if(test $i -gt 11310)
- repo='https://git.9front.org/plan9front/9front/'
- if not
- repo='https://git.9front.org/plan9front/plan9front/'
- echo '<a href="'^$repo^$commit^'/commit.html">'^$commit^'</a>'
- echo '<a href="/9front/9front-'^$i^'.log">Build Logs</a>'
- echo $i^'<br>'
- }
-}
-
-cat $root/footer
--- a/src/execfs/builds/rules
+++ /dev/null
@@ -1,2 +1,0 @@
-/index.html /cfg/$sysname/src/execfs/builds/index.rc
-/man2html/([0-9])/([a-zA-Z0-9\.]+) troff -manhtml /usr/build/code/9front/sys/man/'\1/\2' | troff2html -t '\2(\1)'
--- a/src/execfs/execfs.c
+++ /dev/null
@@ -1,307 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <fcall.h>
-#include <thread.h>
-#include <9p.h>
-
-#include <bio.h>
-#include <regexp.h>
-
-typedef struct Xrule Xrule;
-typedef struct Xfile Xfile;
-
-struct Xrule
-{- Reprog *re;
- char *sub;
- Xrule *next;
-};
-
-struct Xfile
-{- char *path;
- char *dest;
- int fd;
-};
-
-Xrule *rules;
-
-void
-readrules(char *file)
-{- Biobuf *bio;
- char *s, *p, *d;
-
- if((bio = Bopen(file, OREAD)) == nil)
- sysfatal("open: %r");- while(s = Brdstr(bio, '\n', 1)){- Xrule *r;
-
- p = s;
- while(strchr("\t ", *p))- p++;
- d = nil;
- if(*p != '#'){- if(d = strchr(p, '\t'))
- *d++ = 0;
- else if(d = strchr(p, ' '))
- *d++ = 0;
- }
- if(d == nil){- free(s);
- continue;
- }
- while(strchr("\t ", *d))- d++;
-
- r = emalloc9p(sizeof(*r));
- if(r->re = regcomp(p)){- r->sub = estrdup9p(d);
- r->next = rules;
- rules = r;
- } else {- fprint(2, "regcomp failed: %s\n", p);
- free(r);
- }
- free(s);
- }
- Bterm(bio);
-}
-
-char*
-matchrule(char *path)
-{- Xrule *r;
- Resub m[16];
- char *s;
-
- for(r = rules; r; r = r->next){- memset(m, 0, sizeof(m));
- if(regexec(r->re, path, m, nelem(m))){- s = emalloc9p(1024);
- regsub(r->sub, s, 1024, m, nelem(m));
- return s;
- }
- }
- return nil;
-}
-
-ulong
-hash(char *s)
-{- ulong h, t;
- char c;
-
- h = 0;
- while(c = *s++){- t = h & 0xf8000000;
- h <<= 5;
- h ^= t>>27;
- h ^= (ulong)c;
- }
- return h;
-}
-
-void
-fsattach(Req *req)
-{- Xfile *x;
-
- if(req->ifcall.aname && req->ifcall.aname[0]){- respond(req, "invalid attach specifier");
- return;
- }
-
- x = emalloc9p(sizeof(*x));
- x->path = estrdup9p("");- x->dest = nil;
- x->fd = -1;
-
- req->fid->aux = x;
- req->fid->qid.path = hash(x->path);
- req->fid->qid.type = QTDIR;
- req->fid->qid.vers = 0;
- req->ofcall.qid = req->fid->qid;
-
- respond(req, nil);
-}
-
-char*
-fswalk1(Fid *fid, char *name, Qid *qid)
-{- Xfile *x;
- char *p;
-
- if(fid->qid.type != QTDIR)
- return "walk in non-directory";
-
- x = fid->aux;
- if(strcmp(name, ".") == 0){- } else if(strcmp(name, "..") == 0){- if(p = strrchr(x->path, '/'))
- *p = 0;
- } else {- p = smprint("%s/%s", x->path, name);- free(x->path);
- x->path = p;
- }
- fid->qid.path = hash(x->path);
- if(x->dest = matchrule(x->path))
- fid->qid.type = QTFILE;
- else
- fid->qid.type = QTDIR;
- if(qid)
- *qid = fid->qid;
- return nil;
-}
-
-char*
-fsclone(Fid *old, Fid *new)
-{- Xfile *x;
-
- x = emalloc9p(sizeof(*x));
- memmove(x, old->aux, sizeof(*x));
- if(x->path)
- x->path = estrdup9p(x->path);
- if(x->dest)
- x->dest = estrdup9p(x->dest);
- new->aux = x;
- return nil;
-}
-
-void
-fsstat(Req *req)
-{- Xfile *x;
- char *p;
- Dir *d;
-
- x = req->fid->aux;
- d = &req->d;
- memset(d, 0, sizeof(*d));
- d->uid = estrdup9p("execfs");- d->gid = estrdup9p("execfs");- d->atime = d->mtime = time(0);
- if(p = strrchr(x->path, '/'))
- d->name = estrdup9p(p+1);
- else
- d->name = estrdup9p("/");- if(x->dest){- d->qid.type = QTFILE;
- d->mode = 0444;
- }else {- d->qid.type = QTDIR;
- d->mode = DMDIR|0555;
- }
- respond(req, nil);
-}
-
-void
-fsread(Req *req)
-{- int n, pfd[2];
- Xfile *x;
- Srv *srv;
-
- x = req->fid->aux;
- if(x->dest == nil){- req->ofcall.count = 0;
- respond(req, nil);
- return;
- }
- if(x->fd < 0){- if(pipe(pfd) < 0){- responderror(req);
- return;
- }
- if(rfork(RFPROC|RFNOWAIT|RFFDG|RFREND) == 0){- char *argv[4];
- int i;
-
- argv[0] = "rc";
- argv[1] = "-c";
- argv[2] = x->dest;
- argv[3] = nil;
-
- close(0);
- open("/dev/null", OREAD);- dup(pfd[1], 1);
- dup(pfd[1], 2);
- for(i=3; i<20; i++)
- close(i);
- exec("/bin/rc", argv);- exits("exec");- }
- x->fd = pfd[0];
- close(pfd[1]);
- }
- srvrelease(srv = req->srv);
- if((n = read(x->fd, req->ofcall.data, req->ifcall.count)) < 0)
- responderror(req);
- else { - req->ofcall.count = n;
- respond(req, nil);
- }
- srvacquire(srv);
-}
-
-void
-fsclunk(Fid *fid)
-{- Xfile *x;
-
- if(x = fid->aux){- fid->aux = nil;
-
- if(x->fd >= 0)
- close(x->fd);
- free(x->path);
- free(x->dest);
- free(x);
- }
-}
-
-Srv fs = {- .attach = fsattach,
- .stat = fsstat,
- .read = fsread,
- .walk1 = fswalk1,
- .clone = fsclone,
- .destroyfid = fsclunk,
-};
-
-void
-usage(void)
-{- fprint(2, "usage: %s [-D] [-m mtpt] [-s srv] rulefile\n", argv0);
- exits("usage");-}
-
-void
-main(int argc, char *argv[])
-{- char *srv, *mtpt;
-
- srv = nil;
- mtpt = "/n/execfs";
- ARGBEGIN {- case 'D':
- chatty9p++;
- break;
- case 'm':
- mtpt = EARGF(usage());
- break;
- case 's':
- srv = EARGF(usage());
- break;
- default:
- usage();
- } ARGEND;
-
- if(argc != 1)
- usage();
-
- readrules(*argv);
- postmountsrv(&fs, srv, mtpt, MREPL);
-}
--- a/src/execfs/mkfile
+++ /dev/null
@@ -1,8 +1,0 @@
-</$objtype/mkfile
-
-TARG=execfs
-BIN=/$objtype/bin
-
-OFILES=execfs.$O
-
-</sys/src/cmd/mkone
--- a/src/execfs/rules
+++ /dev/null
@@ -1,2 +1,0 @@
-# mount -q /srv/magic /usr/web/magic
-/man2html/([0-9])/([a-zA-Z0-9\.]+) troff -manhtml /sys/man/\1/\2 | troff2html -t '\2(\1)'
--
⑨