feat: improve graceful shutdown — stop bg loop, drain fights, clear state
Shutdown now: 1) stops background fight loop, 2) waits up to 15s for active fights to finish, 3) cancels pending human + poll challenges, 4) clears bet escrow. Added clearEscrow() to betting.ts. Tests verify each cleanup function and shutdown sequence ordering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
023a1a58a9
commit
4134a27ea6
@@ -165,6 +165,16 @@ export async function settleBets(
|
||||
return settlements
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all escrow state (used during graceful shutdown).
|
||||
* Returns the number of fights with open bets that were cleared.
|
||||
*/
|
||||
export function clearEscrow(): number {
|
||||
const count = escrow.size
|
||||
escrow.clear()
|
||||
return count
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active bets for a fight.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user