forked from mirror/MCSManager
Feat: add exit command
This commit is contained in:
parent
7b6a465127
commit
17ceea3b69
24
src/app.ts
24
src/app.ts
@ -134,3 +134,27 @@ function startUp(port: number, host?: string) {
|
||||
}
|
||||
|
||||
startUp(systemConfig.httpPort, systemConfig.httpIp);
|
||||
|
||||
async function processExit() {
|
||||
try {
|
||||
console.log("");
|
||||
logger.warn("Program received EXIT command.");
|
||||
logger.info("Exit.");
|
||||
} catch (err) {
|
||||
logger.error("ERROR:", err);
|
||||
} finally {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
["SIGTERM", "SIGINT", "SIGQUIT"].forEach(function (sig) {
|
||||
process.on(sig, () => {
|
||||
logger.warn(`${sig} close process signal detected.`);
|
||||
processExit();
|
||||
});
|
||||
});
|
||||
|
||||
process.stdin.on("data", (v) => {
|
||||
const command = v.toString().replace("\n", "").replace("\r", "").trim().toLowerCase();
|
||||
if (command === "exit") processExit();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user