* Gets called when all modules are started. * @param {Module[]} moduleObjects All module instances.
(moduleObjects)
| 581 | * @param {Module[]} moduleObjects All module instances. |
| 582 | */ |
| 583 | modulesStarted (moduleObjects) { |
| 584 | modules = []; |
| 585 | let startUp = ""; |
| 586 | |
| 587 | moduleObjects.forEach((module) => modules.push(module)); |
| 588 | |
| 589 | Log.info("All modules started!"); |
| 590 | _sendNotification("ALL_MODULES_STARTED"); |
| 591 | |
| 592 | createDomObjects(); |
| 593 | |
| 594 | // Setup global socket listener for RELOAD event (watch mode) |
| 595 | if (typeof io !== "undefined") { |
| 596 | const socket = io("/", { |
| 597 | path: `${config.basePath || "/"}socket.io` |
| 598 | }); |
| 599 | |
| 600 | socket.on("RELOAD", () => { |
| 601 | Log.warn("Reload notification received from server"); |
| 602 | window.location.reload(true); |
| 603 | }); |
| 604 | } |
| 605 | |
| 606 | if (config.reloadAfterServerRestart) { |
| 607 | setInterval(async () => { |
| 608 | // if server startup time has changed (which means server was restarted) |
| 609 | // the client reloads the mm page |
| 610 | try { |
| 611 | const res = await fetch(`${location.protocol}//${location.host}${config.basePath}startup`); |
| 612 | const curr = await res.text(); |
| 613 | if (startUp === "") startUp = curr; |
| 614 | if (startUp !== curr) { |
| 615 | startUp = ""; |
| 616 | window.location.reload(true); |
| 617 | Log.warn("Refreshing Website because server was restarted"); |
| 618 | } |
| 619 | } catch (err) { |
| 620 | Log.error(`MagicMirror not reachable: ${err}`); |
| 621 | } |
| 622 | }, config.checkServerInterval); |
| 623 | } |
| 624 | }, |
| 625 | |
| 626 | /** |
| 627 | * Send a notification to all modules. |
nothing calls this directly
no test coverage detected