From e74320a8e8638c9028e052a5d6d3545825708839 Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Wed, 22 Apr 2026 23:09:00 +0200 Subject: [PATCH] feat(ingestion): wire watcher into server startup + fix Procfile env vars - Start background watcher on startup when INGEST_WATCH_INTERVAL > 0 - Procfile: add INGEST_WATCH_INTERVAL=30 and INGEST_SVC_URL for supervisor Co-Authored-By: Claude Sonnet 4.6 --- Procfile | 4 ++-- ingestion/cmd/server/main.go | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Procfile b/Procfile index c2171a4..6f14c3e 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -ingestion: cd ingestion && INGEST_BRAIN_DIR=../brain INGEST_PORT=3300 go run ./cmd/server/ -supervisor: SUPERVISOR_CONFIG_DIR=./config/supervisor SUPERVISOR_MODELS_FILE=./config/models.yaml SUPERVISOR_SESSIONS_DIR=./brain/sessions INGEST_BASE_URL=http://localhost:3300 go run ./cmd/supervisor/ +ingestion: cd ingestion && INGEST_BRAIN_DIR=../brain INGEST_PORT=3300 INGEST_WATCH_INTERVAL=30 go run ./cmd/server/ +supervisor: SUPERVISOR_CONFIG_DIR=./config/supervisor SUPERVISOR_MODELS_FILE=./config/models.yaml SUPERVISOR_SESSIONS_DIR=./brain/sessions INGEST_BASE_URL=http://localhost:3300 INGEST_SVC_URL=http://localhost:3300 go run ./cmd/supervisor/ diff --git a/ingestion/cmd/server/main.go b/ingestion/cmd/server/main.go index 2f0c573..194f54a 100644 --- a/ingestion/cmd/server/main.go +++ b/ingestion/cmd/server/main.go @@ -2,6 +2,7 @@ package main import ( + "context" "fmt" "log/slog" "net/http" @@ -12,6 +13,7 @@ import ( "github.com/mathiasbq/hyperguild/ingestion/internal/api" "github.com/mathiasbq/hyperguild/ingestion/internal/llm" "github.com/mathiasbq/hyperguild/ingestion/internal/pipeline" + "github.com/mathiasbq/hyperguild/ingestion/internal/watcher" ) func envOr(key, fallback string) string { @@ -52,8 +54,14 @@ func main() { h := api.NewHandler(brainDir, logger, pipelineCfg) - // TODO(task11): start watcher when INGEST_WATCH_INTERVAL > 0 - _ = watchInterval + ctx := context.Background() + if watchInterval > 0 { + watcher.Start(ctx, watcher.Config{ + BrainDir: brainDir, + Interval: time.Duration(watchInterval) * time.Second, + Pipeline: pipelineCfg, + }) + } mux := http.NewServeMux() mux.HandleFunc("POST /query", h.Query) @@ -64,7 +72,7 @@ func main() { addr := ":" + port watchIntervalLog := "disabled" if watchInterval > 0 { - watchIntervalLog = fmt.Sprintf("%ds (pending task11 wiring)", watchInterval) + watchIntervalLog = fmt.Sprintf("%ds", watchInterval) } logger.Info("ingestion server starting", "addr", addr,