Commit 1569539
Eric Bower
·
2026-08-11 11:29:54 -0400 EDT
parent fe39804
fix: monitor fixes
1 files changed,
+13,
-4
M
main.go
M
main.go
+13,
-4
1@@ -1354,8 +1354,10 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
2 }
3 publishedJSON, _ := json.Marshal(published)
4 log.Info("writing sentinel", "path", sentinel)
5- if err := os.WriteFile(sentinel, publishedJSON, 0644); err != nil {
6- log.Error("write published sentinel", "err", err)
7+ if err := os.MkdirAll(filepath.Dir(sentinel), 0755); err == nil {
8+ if err := os.WriteFile(sentinel, publishedJSON, 0644); err != nil {
9+ log.Error("write published sentinel", "err", err)
10+ }
11 }
12 // Regenerate index.html now that published.json exists, so the artifact list includes it.
13 indexHTML, indexTXT := generateJobIndex(cfg.ArtifactDir, name, jobID, group)
14@@ -1709,8 +1711,15 @@ func publishStatus(w io.Writer, payload StatusPayload) error {
15 if err != nil {
16 return err
17 }
18- _, err = w.Write(append(data, '\n'))
19- return err
20+ if _, err := w.Write(append(data, '\n')); err != nil {
21+ return err
22+ }
23+ if f, ok := w.(interface{ Flush() error }); ok {
24+ _ = f.Flush()
25+ } else if f, ok := w.(*os.File); ok {
26+ _ = f.Sync()
27+ }
28+ return nil
29 }
30
31 func stageArtifact(dir, name, jobID, short, content, ext string) error {