fix: Kill nitro many times app onDispose

This commit is contained in:
hiro 2023-12-13 16:46:49 +07:00
parent 96fa392fba
commit 257011309f

View File

@ -188,18 +188,15 @@ async function validateModelStatus(): Promise<ModelOperationResponse> {
* @returns A Promise that resolves when the subprocess is terminated successfully, or rejects with an error message if the subprocess fails to terminate. * @returns A Promise that resolves when the subprocess is terminated successfully, or rejects with an error message if the subprocess fails to terminate.
*/ */
function killSubprocess(): Promise<void> { function killSubprocess(): Promise<void> {
if (subprocess) { fetch(NITRO_HTTP_KILL_URL, {
return fetch(NITRO_HTTP_KILL_URL, {
method: "DELETE", method: "DELETE",
}).catch((err) => { }).catch((err) => {
console.error(err); console.error(err);
subprocess.kill(); subprocess?.kill();
kill(PORT, "tcp").then(console.log).catch(console.log);
subprocess = null; subprocess = null;
return kill(PORT, "tcp").then(console.log).catch(console.log); });
}); return
} else {
return kill(PORT, "tcp").then(console.log).catch(console.log);
}
} }
/** /**