mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
fix server.close() issue
This commit is contained in:
parent
54b04962a8
commit
0ef6f89d44
11
js/server.js
11
js/server.js
@ -23,6 +23,7 @@ const Utils = require("./utils.js");
|
|||||||
*/
|
*/
|
||||||
function Server(config, callback) {
|
function Server(config, callback) {
|
||||||
const port = process.env.MM_PORT || config.port;
|
const port = process.env.MM_PORT || config.port;
|
||||||
|
const serverSockets = new Set();
|
||||||
|
|
||||||
let server = null;
|
let server = null;
|
||||||
if (config.useHttps) {
|
if (config.useHttps) {
|
||||||
@ -42,6 +43,13 @@ function Server(config, callback) {
|
|||||||
allowEIO3: true
|
allowEIO3: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("connection", (socket) => {
|
||||||
|
serverSockets.add(socket);
|
||||||
|
socket.on("close", () => {
|
||||||
|
serverSockets.delete(socket);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Log.log(`Starting server on port ${port} ... `);
|
Log.log(`Starting server on port ${port} ... `);
|
||||||
|
|
||||||
server.listen(port, config.address || "localhost");
|
server.listen(port, config.address || "localhost");
|
||||||
@ -94,6 +102,9 @@ function Server(config, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.close = function () {
|
this.close = function () {
|
||||||
|
for (const socket of serverSockets.values()) {
|
||||||
|
socket.destroy();
|
||||||
|
}
|
||||||
server.close();
|
server.close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ describe("Display of modules", function () {
|
|||||||
it("should show the test header", function () {
|
it("should show the test header", function () {
|
||||||
elem = document.querySelector("#module_0_helloworld .module-header");
|
elem = document.querySelector("#module_0_helloworld .module-header");
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
|
// textContent gibt hier lowercase zurück, das uppercase wird durch css realisiert, was daher nicht in textContent landet
|
||||||
expect(elem.textContent).toBe("test_header");
|
expect(elem.textContent).toBe("test_header");
|
||||||
//result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show no header if no header text is specified", function () {
|
it("should show no header if no header text is specified", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user