From 03c9d6ba313c793bc31c95bca3c501764eaafc35 Mon Sep 17 00:00:00 2001 From: Ben Carter Date: Mon, 11 Sep 2023 21:38:23 -0400 Subject: [PATCH] updated ets to kill background processes --- .bin/ets.js | 49 ++++++++++++++++++----------------------- modules/server/hello.ts | 1 - 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.bin/ets.js b/.bin/ets.js index 672065b..ddd6620 100755 --- a/.bin/ets.js +++ b/.bin/ets.js @@ -135,39 +135,32 @@ function buildModules(luaDir, moduleDir, watch, liveReload) { tscwatch.start("--outDir", outputDir); } - - - // if (watch && liveReload) { - // log.info(`Starting Eluna watcher... (THIS ONLY WORKS WITH DOCKER CONFIGS!)`); - // const runShellScript = () => { - // const scriptProcess = spawn("./send-reload-eluna.sh"); - - // scriptProcess.stdout.on("close", (data) => { - // log.success("Reloading Eluna complete.."); - // }); - - // scriptProcess.stderr.on("data", (data) => { - // log.error(`Script Error: ${data}`); - // }); - // }; - - // const rerunEluna = _.debounce(runShellScript, 300); - // fs.watch(outputDir, (eventType, filename) => { - // if (eventType === "change" || eventType === "rename") { - // log.info(`Change detected in ${filename}. \nReloading eluna...`); - // rerunEluna(); - // } - // }); - - // log.success("Starting Eluna watcher..."); - // runShellScript(); - // } - } catch (error) { + + // Clean up any processes that are running. + if(tscwatch) { + tscwatch.stop(); + } + + if(reloadprocess) { + reloadprocess.kill(); + } + log.error(`Error occurred: ${error.message}`); process.exit(1); } + // Clean up any processes that are running. + process.on("exit", () => { + if(tscwatch) { + tscwatch.stop(); + } + + if(reloadprocess) { + reloadprocess.kill(); + } + }) + return; } /** diff --git a/modules/server/hello.ts b/modules/server/hello.ts index eb53fbd..b9c5a14 100644 --- a/modules/server/hello.ts +++ b/modules/server/hello.ts @@ -11,7 +11,6 @@ if (command == "hello") { const message = "Hello World command was entered!"; - PrintInfo(message); SendWorldMessage(message); } return true;