summaryrefslogtreecommitdiff
path: root/svc/src/dat.h
diff options
context:
space:
mode:
authorCalvin <calvinm@kissingerassoc.com>2026-08-16 20:52:12 -0400
committerCalvin <calvinm@kissingerassoc.com>2026-08-16 20:52:12 -0400
commit147b0ca1e4e00f66abb47fff3c543b853033f609 (patch)
treea388172fc16723c139deff1e45a74c3d1c567cc0 /svc/src/dat.h
Initial commit: svc supervisor, design docs, session transcript
Existing work moved from /storage/vms/9front/svc, previously unversioned. Object files and linked binaries excluded via .gitignore.
Diffstat (limited to 'svc/src/dat.h')
-rw-r--r--svc/src/dat.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/svc/src/dat.h b/svc/src/dat.h
new file mode 100644
index 0000000..f2cdec2
--- /dev/null
+++ b/svc/src/dat.h
@@ -0,0 +1,85 @@
+/*
+ * Shared between the supervisor (init.c) and the control
+ * filesystem (fs.c).
+ */
+
+enum
+{
+ /* states */
+ Sstopped,
+ Swaiting, /* wants to run; a needs= is not up yet */
+ Sstarting, /* started; not yet ready */
+ Srunning,
+ Sfailed,
+ Sdone, /* ready=exit service that finished cleanly */
+
+ /* kinds, from ready= */
+ Kexec, /* up as soon as started; watch the process */
+ Ksrv, /* up when /srv/x appears; watch that file */
+ Kdial, /* up when a dial succeeds; watch the process */
+ Kexit, /* oneshot; done when it exits cleanly */
+
+ Maxargs = 64,
+ Maxneeds = 32,
+ Maxrestarts = 5, /* within Restartwindow seconds */
+ Restartwindow = 60,
+ Restartwait = 1, /* seconds between restarts */
+ Readywait = 30, /* seconds to become ready */
+ Stopwait = 5, /* seconds before killing */
+ Tickms = 250, /* poll interval */
+};
+
+typedef struct Svc Svc;
+struct Svc
+{
+ char *name;
+ char *exec;
+ char *argv[Maxargs];
+ int argc;
+ char *env[Maxargs];
+ int envc;
+ char *restart;
+ int enable;
+
+ int kind;
+ char *readyarg;
+ char *needs[Maxneeds];
+ int nneeds;
+
+ int wanted; /* should it be running? */
+ int stopping; /* we asked it to go; not a crash */
+ int pid;
+ int state;
+ long tstart;
+ long tstop; /* when we asked it to stop */
+ long tretry; /* earliest time to start again */
+ int restarts;
+ long rtimes[Maxrestarts];
+ int rnext;
+ char *exits;
+
+ int mark; /* cycle detection */
+ Svc *next;
+};
+
+extern Svc *svcs;
+extern char *statename[];
+extern char *svcdir;
+extern char *logdir;
+extern int verbose;
+extern QLock statelock; /* covers svcs and the command queue */
+
+/* init.c */
+Svc* findname(char*);
+void startsvc(Svc*);
+void stopsvc(Svc*);
+char* statusline(Svc*); /* malloc'd ndb line, with newline */
+char* allstatus(void); /* malloc'd, every service */
+
+/* command queue: the filesystem asks, the supervisor acts */
+char* queuecmd(char *verb, char *name); /* nil ok, else error */
+void draincmds(void);
+int cmdspending(void);
+
+/* fs.c */
+void startfs(char *srvname, char *mtpt);