From 799b640dddbbfe6abbf6a10f9a26b91c469068f4 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 29 Jan 2026 09:50:40 -0500 Subject: [PATCH] chore(server): integrate request tracing and auto-start services - Add RequestTracingMiddleware to middleware chain - Auto-start scheduler for auto-scanning on server boot - Auto-start watch mode for all libraries with 2-second delay - Update SetupRoutes to return handler for service management --- cmd/server/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 75ca2ce..65709ed 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -64,6 +64,7 @@ func main() { e.Use(echomiddleware.Logger()) e.Use(echomiddleware.Recover()) e.Use(echomiddleware.CORS()) + e.Use(ratelimit.RequestTracingMiddleware(cfg)) // Rate limiter for auth endpoints rateLimiter := ratelimit.NewRateLimiter(ratelimit.DefaultRateLimiterConfig()) @@ -148,7 +149,19 @@ func main() { e.Static("/static", "static") // Routes - handlers.SetupRoutes(protected, queries) + h := handlers.SetupRoutes(protected, queries) + + // Start scheduler for auto-scanning + go h.StartScheduler() + defer h.StopScheduler() + + // Start watch mode for all libraries (background) + go func() { + time.Sleep(2 * time.Second) // Wait a bit for server to be ready + if err := h.StartWatchModeForAllLibraries(context.Background()); err != nil { + log.Printf("Warning: failed to start watch mode for libraries: %v", err) + } + }() // Dashboard route (protected) protected.GET("/dashboard", func(c echo.Context) error {