@@ -30,6 +30,7 @@ import { S3Service } from "src/s3/s3.service";
3030import { ChatService } from "src/chat/chat.service" ;
3131import { ChatLobbyType } from "src/chat/enums/ChatLobbyTypes" ;
3232import { MatchRelayService } from "./match-relay/match-relay.service" ;
33+ import { RestartDedicatedServer } from "./jobs/RestartDedicatedServer" ;
3334
3435@Controller ( "matches" )
3536export class MatchesController {
@@ -345,41 +346,33 @@ export class MatchesController {
345346 } ,
346347 } ) ;
347348
348- if ( server . is_dedicated ) {
349- await this . matchAssistant . restartDedicatedServer ( serverId ) ;
350- } else {
351- if ( status === "Canceled" || data . op === "DELETE" ) {
352- await this . matchAssistant . stopOnDemandServer ( matchId ) ;
353- } else {
354- const { match_options_by_pk : matchOptions } = await this . hasura . query (
355- {
356- match_options_by_pk : {
357- __args : {
358- id : data . new . match_options_id ,
359- } ,
360- tv_delay : true ,
361- } ,
362- } ,
363- ) ;
364-
365- if ( ! matchOptions ) {
366- await this . matchAssistant . stopOnDemandServer ( matchId ) ;
367- } else {
368- const tvDelay = matchOptions . tv_delay || 0 ;
369-
370- this . logger . log (
371- `[${ matchId } ] adding stop on demand server job in ${ tvDelay } seconds` ,
372- ) ;
373-
374- await this . scheduledMatchesQueue . add (
375- StopOnDemandServer . name ,
376- { matchId } ,
377- tvDelay ? { delay : tvDelay * 1000 } : undefined ,
378- ) ;
379- }
380- }
349+ const { match_options_by_pk : matchOptions } = await this . hasura . query ( {
350+ match_options_by_pk : {
351+ __args : {
352+ id : data . new . match_options_id ,
353+ } ,
354+ tv_delay : true ,
355+ } ,
356+ } ) ;
357+
358+ let delay = matchOptions ?. tv_delay || 1 ;
359+
360+ if ( status === "Canceled" || data . op === "DELETE" ) {
361+ delay = 0 ;
381362 }
382363
364+ this . logger . log (
365+ `[${ matchId } ] adding stop / restart server job in ${ delay } seconds` ,
366+ ) ;
367+
368+ await this . scheduledMatchesQueue . add (
369+ server . is_dedicated
370+ ? RestartDedicatedServer . name
371+ : StopOnDemandServer . name ,
372+ { serverId } ,
373+ delay ? { delay : delay * 1000 } : undefined ,
374+ ) ;
375+
383376 await this . hasura . mutation ( {
384377 update_matches_by_pk : {
385378 __args : {
0 commit comments