forked from nasa-gcn/architect-plugin-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runBinary.ts
34 lines (30 loc) · 893 Bytes
/
runBinary.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*!
* Copyright © 2023 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
import { spawn, untilTerminated } from './processes.js'
import { type SearchEngineLauncherFunction } from './run.js'
export const launchBinary: SearchEngineLauncherFunction<{
bin: string
}> = async ({ bin, dataDir, logsDir, options }) => {
const args = [...options, `path.data=${dataDir}`, `path.logs=${logsDir}`].map(
(opt) => `-E${opt}`
)
console.log('Spawning', bin, ...args)
const child = await spawn(bin, args, {
stdio: ['ignore', 'ignore', 'inherit'],
shell: true,
})
return {
async kill() {
console.log('Killing child process')
child.kill()
},
async waitUntilStopped() {
await untilTerminated(child)
},
}
}