9p: add b/cleanup script to server

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-18 12:39:33 +02:00
parent 80b7d1aad6
commit 237e4dec8c
2 changed files with 6 additions and 4 deletions

View File

@ -34,6 +34,7 @@ ollie/
job exec: core batch job runner (submit, wait, print result)
q exec: foreground one-shot query; thin wrapper around job
sched exec: submit background job; prints b/ path; wrapper around job
cleanup exec: remove all jobs with status "done"
<job-id>/ rm -r to cancel and remove
spec read: original job spec as submitted
status read: running | done | failed: <reason>

View File

@ -339,7 +339,7 @@ func (s *Server) pathType(path string) string {
return "dir"
case len(parts) == 2 && parts[0] == "b":
switch parts[1] {
case "new", "idx", "job", "q", "sched":
case "new", "idx", "job", "q", "sched", "cleanup":
return "file"
default:
if _, err := s.batchStore.Stat(parts[1]); err == nil {
@ -575,7 +575,7 @@ func (s *Server) read(cs *connState, fc *plan9.Fcall) *plan9.Fcall {
}
return s.readSlice(fc, content)
}
if path == "/b/job" || path == "/b/q" || path == "/b/sched" {
if path == "/b/job" || path == "/b/q" || path == "/b/sched" || path == "/b/cleanup" {
plog.Debug("Tread path=%q offset=%d count=%d", path, fc.Offset, fc.Count)
content, err := os.ReadFile(paths.CfgDir() + "/scripts/b/" + pathBase(path))
if err != nil {
@ -1393,6 +1393,7 @@ func (s *Server) readDir(path string, offset uint64, count uint32) []byte {
dirs = append(dirs, makeDir("job", "/b/job", false, 0555))
dirs = append(dirs, makeDir("q", "/b/q", false, 0555))
dirs = append(dirs, makeDir("sched", "/b/sched", false, 0555))
dirs = append(dirs, makeDir("cleanup", "/b/cleanup", false, 0555))
entries, _ := s.batchStore.List()
for _, e := range entries {
isDir := e.IsDir()
@ -1519,7 +1520,7 @@ func (s *Server) makeStat(path string) plan9.Dir {
mode = 0777
} else if strings.HasPrefix(path, "/u/") {
mode = 0555
} else if path == "/b/job" || path == "/b/q" || path == "/b/sched" {
} else if path == "/b/job" || path == "/b/q" || path == "/b/sched" || path == "/b/cleanup" {
mode = 0555
} else {
mode = 0444
@ -1606,7 +1607,7 @@ func (s *Server) makeStat(path string) plan9.Dir {
if content, err := s.utilStore.Get(base); err == nil {
dir.Length = uint64(len(content))
}
case path == "/b/job" || path == "/b/q" || path == "/b/sched":
case path == "/b/job" || path == "/b/q" || path == "/b/sched" || path == "/b/cleanup":
if content, err := os.ReadFile(paths.CfgDir() + "/scripts/b/" + base); err == nil {
dir.Length = uint64(len(content))
}