Address production-readiness review: clearer errors, safer votes, and ops hardening.
Distinguish auth/lookup failures, make votes idempotent on visible questions, bound shutdown, page admin users, LRU throttle, trusted-proxy CIDRs, avatar cleanup, versioned migrations, and session cleanup logging.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -103,10 +104,21 @@ func (s *SessionStore) cleanupLoop(interval time.Duration) {
|
||||
defer close(s.stopped)
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
var lastErrLog time.Time
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
_ = s.q.DeleteExpiredSessions(context.Background())
|
||||
n, err := s.q.DeleteExpiredSessions(context.Background())
|
||||
if err != nil {
|
||||
if time.Since(lastErrLog) > time.Minute {
|
||||
log.Printf("session cleanup: %v", err)
|
||||
lastErrLog = time.Now()
|
||||
}
|
||||
continue
|
||||
}
|
||||
if n > 0 {
|
||||
log.Printf("session cleanup: deleted %d expired row(s)", n)
|
||||
}
|
||||
case <-s.stop:
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user