feat(worker): enforce image processing timeout with child process

This commit is contained in:
kk10
2026-11-16 15:52:49 +03:00
parent be10119910
commit 97b43a9c98
5 changed files with 135 additions and 24 deletions
+18
View File
@@ -2,6 +2,8 @@ package main
import (
"context"
"errors"
"flag"
"fmt"
"os"
"os/signal"
@@ -17,6 +19,22 @@ import (
)
func main() {
maxPixels := flag.Int("process-image", 0, "process an image from stdin with the given pixel limit")
flag.Parse()
if *maxPixels > 0 {
if err := worker.ProcessImage(*maxPixels); err != nil {
if errors.Is(err, worker.ErrInvalidSource) {
os.Exit(2)
}
fmt.Fprintln(os.Stderr, "process image:", err)
os.Exit(1)
}
return
}
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "worker:", err)
os.Exit(1)