diff --git a/internal/router/router.go b/internal/router/router.go index 6b85f7a..9475cd0 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -10,6 +10,7 @@ import ( "bookhoard/internal/sync" "bookhoard/templates" "bytes" + "context" "log" "net/http" "strings" @@ -234,6 +235,17 @@ func RegisterRoutes(cfg *Config) *handlers.Handler { // Start background tasks (queue processor and connection cleanup) scannerHandler.StartBackgroundTasks() + // Start watch mode for all libraries (after 2 second delay for DB) + go func() { + time.Sleep(2 * time.Second) + log.Println("Starting watch mode for all libraries...") + if err := scannerHandler.StartWatchModeForAllLibraries(context.Background()); err != nil { + log.Printf("Failed to start watch mode: %v", err) + } else { + log.Println("Watch mode started successfully") + } + }() + // Register progress routes with actual handler registerProgressRoutes(cfg, scannerHandler)