feat(auth): delete expired sessions hourly

This commit is contained in:
kk10
2026-10-05 15:11:24 +03:00
parent 79036b0f18
commit 7b92ca2366
2 changed files with 47 additions and 0 deletions
+11
View File
@@ -41,6 +41,17 @@ func Run() error {
queries := db.New(pool)
cleanupCtx, stopCleanup := context.WithCancel(context.Background())
cleanupDone := make(chan struct{})
go func() {
defer close(cleanupDone)
runSessionCleanup(cleanupCtx, log, queries, sessionCleanupInterval)
}()
defer func() {
stopCleanup()
<-cleanupDone
}()
authService := service.NewAuthService(queries, cfg.Server.SessionTTL)
userService := service.NewUserService(queries)
chatService := service.NewChatService(pool, queries)