diff --git a/README.md b/README.md index b5b87d1..0d8bf49 100644 --- a/README.md +++ b/README.md @@ -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" / rm -r to cancel and remove spec read: original job spec as submitted status read: running | done | failed: diff --git a/internal/p9/server.go b/internal/p9/server.go index e998f32..d29fbd4 100644 --- a/internal/p9/server.go +++ b/internal/p9/server.go @@ -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)) }