File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -345,11 +345,17 @@ export class DedicatedServersService {
345345 await this . pingDedicatedServer ( serverId ) ;
346346 } , 10000 ) ;
347347 } )
348- . catch ( ( error ) => {
348+ . catch ( async ( error ) => {
349349 this . logger . error (
350- `[${ serverId } ] error waiting for pod to be ready` ,
350+ `[${ serverId } ] error waiting for pod to be ready, recovering server state ` ,
351351 error ,
352352 ) ;
353+ await this . removeDedicatedServer ( serverId ) . catch ( ( removeError ) => {
354+ this . logger . error (
355+ `[${ serverId } ] failed to clean up server after pod readiness failure` ,
356+ removeError ,
357+ ) ;
358+ } ) ;
353359 } ) ;
354360
355361 return true ;
Original file line number Diff line number Diff line change 11import { Job } from "bullmq" ;
22import { WorkerHost } from "@nestjs/bullmq" ;
3+ import { Logger } from "@nestjs/common" ;
34import { MatchQueues } from "../enums/MatchQueues" ;
45import { UseQueue } from "../../utilities/QueueProcessors" ;
56import { PostgresService } from "../../postgres/postgres.service" ;
67
78@UseQueue ( "Matches" , MatchQueues . EloCalculation )
89export class EloCalculation extends WorkerHost {
10+ private readonly logger = new Logger ( EloCalculation . name ) ;
11+
912 constructor ( private readonly postgres : PostgresService ) {
1013 super ( ) ;
1114 }
1215
1316 async process ( job : Job ) : Promise < void > {
1417 const { matchId } = job . data ;
1518
16- await this . postgres . query (
17- `
18- SELECT generate_player_elo_for_match($1)
19- ` ,
20- [ matchId ] ,
21- ) ;
19+ try {
20+ await this . postgres . query (
21+ `
22+ SELECT generate_player_elo_for_match($1)
23+ ` ,
24+ [ matchId ] ,
25+ ) ;
26+ } catch ( error ) {
27+ this . logger . error (
28+ `ELO calculation failed for match ${ matchId } (attempt ${ job . attemptsMade + 1 } )` ,
29+ error ,
30+ ) ;
31+ throw error ;
32+ }
2233 }
2334}
Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ import { DiscordTournamentVoiceModule } from "../discord-bot/discord-tournament-
7575 } ,
7676 {
7777 name : MatchQueues . EloCalculation ,
78+ defaultJobOptions : {
79+ attempts : 3 ,
80+ backoff : { type : "exponential" , delay : 5000 } ,
81+ } ,
7882 } ,
7983 ) ,
8084 BullBoardModule . forFeature (
You can’t perform that action at this time.
0 commit comments