Skip to content

Commit 535ae89

Browse files
committed
chore(scripts): log msg on SIGTERM & SIGINT in inactive accts script
1 parent 608f3e2 commit 535ae89

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/fxa-auth-server/scripts/delete-inactive-accounts/enqueue-inactive-account-deletions.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ const init = async () => {
238238
return 0;
239239
}
240240

241+
(() => {
242+
let deathInProgress = false;
243+
const bail = async (signal) => {
244+
if (deathInProgress) return;
245+
deathInProgress = true;
246+
console.error(`Received ${signal}, shutting down...?`);
247+
248+
// flush buffers if we can
249+
await Promise.allSettled([
250+
new Promise((resolve) => process.stdout.write('', resolve)),
251+
new Promise((resolve) => process.stderr.write('', resolve)),
252+
]);
253+
};
254+
255+
process.once('SIGTERM', async () => await bail('SIGTERM'));
256+
process.once('SIGINT', async () => await bail('SIGINT'));
257+
})();
258+
241259
const debugLog = (message: string) => {
242260
if (!program.debug) return;
243261
console.log(message);

0 commit comments

Comments
 (0)