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 {