final POC
This commit is contained in:
@@ -188,6 +188,17 @@ AppDataSource.initialize()
|
||||
container.setSocketIO(webSocketService['io']);
|
||||
gameWebSocketService = container.gameWebSocketService;
|
||||
logStartup('Game WebSocket service initialized for /game namespace');
|
||||
|
||||
// Restore active games from snapshots (if any exist)
|
||||
gameWebSocketService.restoreAllActiveGames()
|
||||
.then(restoredCount => {
|
||||
if (restoredCount > 0) {
|
||||
logStartup(`Restored ${restoredCount} active game(s) from snapshots`);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
logError('Failed to restore games from snapshots', error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
const dbOptions = AppDataSource.options as any;
|
||||
@@ -225,6 +236,16 @@ const server = httpServer.listen(PORT, () => {
|
||||
const gracefulShutdown = async (signal: string) => {
|
||||
logStartup(`Received ${signal}. Shutting down gracefully...`);
|
||||
|
||||
// Snapshot all active games before shutdown
|
||||
if (gameWebSocketService) {
|
||||
try {
|
||||
const snapshotCount = await gameWebSocketService.snapshotAllActiveGames();
|
||||
logStartup(`Created ${snapshotCount} game snapshot(s) before shutdown`);
|
||||
} catch (error) {
|
||||
logError('Failed to snapshot games before shutdown', error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
server.close(() => {
|
||||
logStartup('HTTP server closed');
|
||||
|
||||
|
||||
@@ -273,10 +273,11 @@ router.delete('/users/:userId',
|
||||
try {
|
||||
const targetUserId = req.params.userId;
|
||||
const adminUserId = (req as any).user.userId;
|
||||
const softDelete = req.query.soft === 'true' || req.query.soft === undefined;
|
||||
|
||||
logRequest('Delete user endpoint accessed', req, res, { adminUserId, targetUserId });
|
||||
logRequest('Delete user endpoint accessed', req, res, { adminUserId, targetUserId, softDelete });
|
||||
|
||||
const result = await container.deleteUserCommandHandler.execute({ id: targetUserId });
|
||||
const result = await container.deleteUserCommandHandler.execute({ id: targetUserId, soft: softDelete });
|
||||
|
||||
if (!result) {
|
||||
return res.status(404).json({ error: 'User not found' });
|
||||
|
||||
Reference in New Issue
Block a user