add SIGINT

This commit is contained in:
lucaspalomodevelop 2022-03-02 19:12:42 +01:00
parent 8632c73d1d
commit fafd02352c
2 changed files with 16 additions and 2 deletions

View File

@ -1,7 +1,12 @@
let conf = require("./helper/conf")();
let websrv = require("./websrv")(conf);
websrv.slisten((host, port) => {
console.log("Server started on http://" + host + ":" + port);
});
process.on("SIGINT", () => {
console.log("\nWeb-Server Beenden ...");
websrv.close();
process.exit();
});

View File

@ -14,8 +14,17 @@ module.exports = function (conf) {
app.use("/internal", internalRouter);
app.slisten = function (cb) {
app.ServerInstance = app.listen(
websrvConfig.port,
websrvConfig.host,
() => {
cb(websrvConfig.host, websrvConfig.port);
}
);
};
app.listen(websrvConfig.port, websrvConfig.host, () => {cb(websrvConfig.host, websrvConfig.port);});
app.close = function () {
app.ServerInstance.close();
};
return app;