From 464c8e45135c9ed034a838dbe532a77d4dd11859 Mon Sep 17 00:00:00 2001 From: Courey Elliott Date: Wed, 12 Jun 2024 15:14:47 -0400 Subject: [PATCH] changing target so we can await at top level --- launchSearch.ts | 25 ++++--------------------- tsconfig.json | 4 +++- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/launchSearch.ts b/launchSearch.ts index 21669b2..0523527 100644 --- a/launchSearch.ts +++ b/launchSearch.ts @@ -15,8 +15,6 @@ type Message = { const [, , argv] = process.argv const { dataDir, logsDir, engine, port, options } = JSON.parse(argv) -let dockerContainer: Dockerode.Container - async function launchDocker() { const Image = engine === 'elasticsearch' @@ -45,29 +43,14 @@ async function launchDocker() { return container } -async function waiting() { - await dockerContainer.wait() - process.exit(0) -} - -async function launch() { - dockerContainer = await launchDocker() - waiting() -} - -process.once('message', async (message: Message) => { - if (message.action === 'kill') { - await dockerContainer.kill() - process.exit(0) - } -}) +const dockerContainer = await launchDocker() -launch() - -const signals = ['SIGTERM', 'SIGINT'] +const signals = ['message', 'SIGTERM', 'SIGINT'] signals.forEach((signal) => { process.on(signal, async () => { await dockerContainer.kill() process.exit(0) }) }) + +await dockerContainer.wait() diff --git a/tsconfig.json b/tsconfig.json index f9825c3..cad99b7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "@tsconfig/node14/tsconfig.json", "compilerOptions": { - "resolveJsonModule": true + "resolveJsonModule": true, + "module": "esnext", + "target": "es2022" } }