Skip to content

Commit 90760d1

Browse files
committed
Fix job cleanup
1 parent b559098 commit 90760d1

7 files changed

+19
-12
lines changed

apps/worker/src/workers/fillClanActivePlayerCount.ts

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { prisma } from "../prisma";
33
import { QUEUE_NAME_FILL_CLAN_ACTIVE_PLAYER_COUNT } from "@teerank/teerank";
44
import { bullmqConnection } from "@teerank/teerank";
55
import { redisClient } from "../redis";
6+
import { minutesToSeconds } from "date-fns";
67

78
const MIN_CREATED_AT_KEY = 'fill-clan-active-player-count-min-created-at';
89

@@ -59,5 +60,11 @@ export async function startFillClanActivePlayerCountWorker() {
5960
return new Worker(QUEUE_NAME_FILL_CLAN_ACTIVE_PLAYER_COUNT, processor, {
6061
connection: bullmqConnection,
6162
concurrency: 1,
63+
removeOnComplete: {
64+
age: minutesToSeconds(10),
65+
},
66+
removeOnFail: {
67+
count: 1000,
68+
}
6269
});
6370
}

apps/worker/src/workers/pollGameServer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Job, Worker } from "bullmq";
77
import { bullmqConnection } from "@teerank/teerank";
88
import { getEnvInt } from "@teerank/teerank";
99
import { uniqBy } from "lodash";
10-
import { minutesToMilliseconds } from "date-fns";
10+
import { minutesToSeconds } from "date-fns";
1111

1212
const POLL_GAME_SERVER_CONCURRENCY = getEnvInt('POLL_GAME_SERVER_CONCURRENCY', 100);
1313

@@ -447,7 +447,7 @@ export async function startPollGameServerWorker() {
447447
connection: bullmqConnection,
448448
concurrency: POLL_GAME_SERVER_CONCURRENCY,
449449
removeOnComplete: {
450-
age: minutesToMilliseconds(10),
450+
age: minutesToSeconds(10),
451451
},
452452
removeOnFail: {
453453
count: 1000,

apps/worker/src/workers/pollMasterServer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { resetPackets, getReceivedPackets, sendData, setupSockets, listenForPack
55
import { QUEUE_NAME_POLL_MASTER_SERVER, wait } from "@teerank/teerank";
66
import { Job, Worker } from "bullmq";
77
import { bullmqConnection } from "@teerank/teerank";
8-
import { minutesToMilliseconds } from "date-fns";
8+
import { minutesToSeconds } from "date-fns";
99

1010
function stringToCharCode(str: string) {
1111
return str.split('').map((char) => char.charCodeAt(0));
@@ -94,7 +94,7 @@ export async function startPollMasterServerWorker() {
9494
return new Worker(QUEUE_NAME_POLL_MASTER_SERVER, processor, {
9595
connection: bullmqConnection,
9696
removeOnComplete: {
97-
age: minutesToMilliseconds(10),
97+
age: minutesToSeconds(10),
9898
},
9999
removeOnFail: {
100100
count: 1000,

apps/worker/src/workers/rankPlayer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { rankPlayersTime } from "../rankMethods/rankPlayersTime";
55
import { Worker } from "bullmq";
66
import { bullmqConnection, QUEUE_NAME_RANK_PLAYER } from "@teerank/teerank";
77
import { getEnvInt } from "@teerank/teerank";
8-
import { minutesToMilliseconds } from "date-fns";
8+
import { minutesToSeconds } from "date-fns";
99

1010
const RANK_PLAYER_CONCURRENCY = getEnvInt('RANK_PLAYER_CONCURRENCY', 20);
1111

@@ -43,7 +43,7 @@ export async function startRankPlayerWorker() {
4343
connection: bullmqConnection,
4444
concurrency: RANK_PLAYER_CONCURRENCY,
4545
removeOnComplete: {
46-
age: minutesToMilliseconds(10),
46+
age: minutesToSeconds(10),
4747
},
4848
});
4949
}

apps/worker/src/workers/updateGameTypesCounts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Worker } from "bullmq";
22
import { prisma } from "../prisma";
33
import { bullmqConnection, QUEUE_NAME_GAME_TYPE_COUNT } from "@teerank/teerank"
44
import { getEnvInt } from "@teerank/teerank";
5-
import { minutesToMilliseconds } from "date-fns";
5+
import { minutesToSeconds } from "date-fns";
66

77
const UPDATE_GAME_TYPES_COUNTS_CONCURRENCY = getEnvInt('UPDATE_GAME_TYPES_COUNTS_CONCURRENCY', 5);
88

@@ -50,7 +50,7 @@ export async function startUpdateGameTypesCountsWorker() {
5050
connection: bullmqConnection,
5151
concurrency: UPDATE_GAME_TYPES_COUNTS_CONCURRENCY,
5252
removeOnComplete: {
53-
age: minutesToMilliseconds(10),
53+
age: minutesToSeconds(10),
5454
},
5555
removeOnFail: {
5656
count: 1000,

apps/worker/src/workers/updateMapsCounts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Worker } from "bullmq";
22
import { prisma } from "../prisma";
33
import { bullmqConnection, QUEUE_NAME_MAP_COUNT } from "@teerank/teerank"
44
import { getEnvInt } from "@teerank/teerank";
5-
import { minutesToMilliseconds } from "date-fns";
5+
import { minutesToSeconds } from "date-fns";
66

77
const UPDATE_MAPS_COUNTS_CONCURRENCY = getEnvInt('UPDATE_MAPS_COUNTS_CONCURRENCY', 5);
88

@@ -55,7 +55,7 @@ export async function startUpdateMapsCountsWorker() {
5555
connection: bullmqConnection,
5656
concurrency: UPDATE_MAPS_COUNTS_CONCURRENCY,
5757
removeOnComplete: {
58-
age: minutesToMilliseconds(10),
58+
age: minutesToSeconds(10),
5959
},
6060
removeOnFail: {
6161
count: 1000,

apps/worker/src/workers/updatePlayTime.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prisma } from "../prisma";
2-
import { differenceInSeconds, minutesToMilliseconds } from "date-fns";
2+
import { differenceInSeconds, minutesToSeconds } from "date-fns";
33
import { removeDuplicatedClients } from "../utils";
44
import { Worker } from "bullmq";
55
import { bullmqConnection, QUEUE_NAME_UPDATE_PLAY_TIME } from "@teerank/teerank";
@@ -254,7 +254,7 @@ export async function startUpdatePlayTimeWorker() {
254254
connection: bullmqConnection,
255255
concurrency: UPDATE_PLAY_TIME_CONCURRENCY,
256256
removeOnComplete: {
257-
age: minutesToMilliseconds(10),
257+
age: minutesToSeconds(10),
258258
},
259259
});
260260
}

0 commit comments

Comments
 (0)