feat: Add the stop/start loop for the service

This commit is contained in:
J H
2024-03-06 10:55:21 -07:00
parent 093a5d4ddf
commit 8410929e86
5 changed files with 52 additions and 13 deletions

View File

@@ -246,7 +246,7 @@ export const createUtils = <
console.error(data.toString())
})
childProcess.on("close", (code: any) => {
childProcess.on("exit", (code: any) => {
if (code === 0) {
return resolve(null)
}
@@ -262,7 +262,7 @@ export const createUtils = <
try {
childProcess.kill(signal)
if (timeout <= NO_TIMEOUT) {
if (timeout > NO_TIMEOUT) {
const didTimeout = await Promise.race([
new Promise((resolve) => setTimeout(resolve, timeout)).then(
() => true,
@@ -270,6 +270,7 @@ export const createUtils = <
answer.then(() => false),
])
if (didTimeout) childProcess.kill(SIGKILL)
return
}
await answer
} finally {