Skip to content

Commit

Permalink
changing target so we can await at top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Courey committed Jun 12, 2024
1 parent bd153a2 commit 464c8e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
25 changes: 4 additions & 21 deletions launchSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
"resolveJsonModule": true,
"module": "esnext",
"target": "es2022"
}
}

0 comments on commit 464c8e4

Please sign in to comment.