generated from technologiestiftung/template-repo-citylab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (20 loc) · 788 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
setTimeout(async () => {
const { bluetoothSerialMonitors } = await import(
"./services/bluetooth/bluetooth.js"
);
const { server } = await import("./services/rest/rest.js");
const { webSocketServer } = await import("./services/socket/socket.js");
const { gpioProcess } = await import("./services/gpio/gpio.js");
// await import("./services/print/print.js");
await import("./services/browser/browser.js");
process.on("SIGINT", () => closeEverything(1));
process.on("SIGTERM", () => closeEverything(0));
function closeEverything(eventId) {
server.close();
webSocketServer.clients.forEach((client) => client.close());
webSocketServer.close();
gpioProcess.kill();
bluetoothSerialMonitors.forEach((monitor) => monitor.kill());
process.exit(eventId);
}
}, 10_000);