forked from mtusi2026/mtusi2026lab2
feat(auth): delete expired sessions hourly
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user