Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maamalama committed Sep 20, 2024
1 parent 556242f commit a65c70a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions valhalla/jawn/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ const KAFKA_ENABLED = (KAFKA_CREDS?.KAFKA_ENABLED ?? "false") === "true";

if (KAFKA_ENABLED) {
startConsumers({
dlqCount: 0,
normalCount: 0,
scoresCount: 0,
scoresDlqCount: 0,
dlqCount: DLQ_WORKER_COUNT,
normalCount: NORMAL_WORKER_COUNT,
scoresCount: SCORES_WORKER_COUNT,
scoresDlqCount: SCORES_WORKER_COUNT,
backFillCount: 0,
});
}
Expand Down Expand Up @@ -205,6 +205,7 @@ server.on("error", console.error);

server.setTimeout(1000 * 60 * 10); // 10 minutes

//This shuts down the server and all delayed operations with delay only locally, on AWS it will be killed by the OS with no delay
async function gracefulShutdown(signal: string) {
console.log(`Received ${signal}. Starting graceful shutdown...`);

Expand All @@ -223,7 +224,7 @@ async function gracefulShutdown(signal: string) {
"Could not close connections in time, forcefully shutting down"
);
process.exit(1);
}, 60000 * 3);
}, 30000);
}

process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
Expand Down
2 changes: 1 addition & 1 deletion valhalla/jawn/src/lib/shared/delayedOperationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export class DelayedOperationService {
private static instance: DelayedOperationService;
private delayedOperations: Map<NodeJS.Timeout, () => Promise<any>> =
new Map();
private static readonly SHUTDOWN_TIMEOUT = 60000 * 3; // 3 minutes timeout
private static readonly SHUTDOWN_TIMEOUT = 30000; // 30 seconds timeout

public static getInstance(): DelayedOperationService {
if (!DelayedOperationService.instance) {
Expand Down
4 changes: 4 additions & 0 deletions valhalla/jawn/src/lib/stores/ScoreStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export class ScoreStore extends BaseStore {
feedback.responseId !== "00000000-0000-0000-0000-000000000000"
);

if (validFeedbacks.length === 0) {
return ok([]);
}

console.log(
`Upserting feedback for ${
validFeedbacks.length
Expand Down

0 comments on commit a65c70a

Please sign in to comment.