fix(storage): stream job output in real-time with StdoutPipe/StderrPipe

- Replace blocking outBuf/errBuf capture with StdoutPipe+StderrPipe + goroutines
- scanAndEmit runs in parallel for stdout and stderr, emitting each line
  via SSE broadcast and DB append immediately (not after cmd.Run completes)
- Custom scanner split: bytes.TrimRight strips trailing \r so snapraid
  progress lines (e.g. '2%, 57396 MB\r') are stored as clean lines
- scanner.Buffer increased to 128KB max to handle large outputs
- Use sync.WaitGroup to ensure both scanners finish before MarkJobFinished
- Fix PID capture: cmd.Process is nil before cmd.Start(), pass 0 instead
This commit is contained in:
2026-07-07 09:07:08 -04:00
parent d42a0ab412
commit 5b459c0b2e
2 changed files with 54 additions and 37 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
BINARY=nasctl
VERSION?=0.8.1
VERSION?=0.8.2
GO?=go
LDFLAGS=-s -w -X github.com/darroyo/nasctl/internal/web.Version=$(VERSION) -X github.com/darroyo/nasctl/internal/web.Commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_FLAGS=CGO_ENABLED=0