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
This commit is contained in:
+14
-1
@@ -64,6 +64,7 @@ func main() {
|
|||||||
e.Use(echomiddleware.Logger())
|
e.Use(echomiddleware.Logger())
|
||||||
e.Use(echomiddleware.Recover())
|
e.Use(echomiddleware.Recover())
|
||||||
e.Use(echomiddleware.CORS())
|
e.Use(echomiddleware.CORS())
|
||||||
|
e.Use(ratelimit.RequestTracingMiddleware(cfg))
|
||||||
|
|
||||||
// Rate limiter for auth endpoints
|
// Rate limiter for auth endpoints
|
||||||
rateLimiter := ratelimit.NewRateLimiter(ratelimit.DefaultRateLimiterConfig())
|
rateLimiter := ratelimit.NewRateLimiter(ratelimit.DefaultRateLimiterConfig())
|
||||||
@@ -148,7 +149,19 @@ func main() {
|
|||||||
e.Static("/static", "static")
|
e.Static("/static", "static")
|
||||||
|
|
||||||
// Routes
|
// 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)
|
// Dashboard route (protected)
|
||||||
protected.GET("/dashboard", func(c echo.Context) error {
|
protected.GET("/dashboard", func(c echo.Context) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user