added close event

This commit is contained in:
srgooglo 2022-05-05 09:46:50 +02:00
parent 56f3d95423
commit c7a712e25f

View File

@ -122,6 +122,11 @@ class Server {
// output server info // output server info
console.log(`✅ Server is up and running!`) console.log(`✅ Server is up and running!`)
this.consoleOutputServerInfo() this.consoleOutputServerInfo()
// handle exit events
process.on("SIGTERM", this.cleanupProcess)
process.on("SIGINT", this.cleanupProcess)
process.on("exit", this.cleanupProcess)
} }
handleWSClientConnection = async (socket) => { handleWSClientConnection = async (socket) => {
@ -288,6 +293,13 @@ class Server {
"HTTP port": this.HTTPlistenPort, "HTTP port": this.HTTPlistenPort,
}) })
} }
cleanupProcess = () => {
console.log("🔴 Stopping server...")
this.httpInterface.close()
this.wsInterface.io.close()
}
} }
module.exports = Server module.exports = Server