fix: clean up stale active sessions on startup
After an unclean shutdown, sessions could be left with disconnected_at NULL, appearing permanently active. Add CloseActiveSessions to the Store interface and call it at startup to close any leftover sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,13 @@ func run() error {
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
// Clean up sessions left active by a previous unclean shutdown.
|
||||
if n, err := store.CloseActiveSessions(context.Background(), time.Now()); err != nil {
|
||||
return fmt.Errorf("close stale sessions: %w", err)
|
||||
} else if n > 0 {
|
||||
logger.Info("closed stale sessions from previous run", "count", n)
|
||||
}
|
||||
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user