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" } }