mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-03 14:26:07 +00:00
Fix loading of multiple instances of node_helper when multiple instances of a module are in config.js (#3517)
adds a check for already loaded/loading for node helper of a each module, only does once fixes #3502
This commit is contained in:
parent
76d8f98969
commit
780e4e2e06
@ -26,6 +26,7 @@ _This release is scheduled to be released on 2024-10-01._
|
|||||||
|
|
||||||
- Fixed `checks` badge in README.md
|
- Fixed `checks` badge in README.md
|
||||||
- [weather] Fixed issue with the UK Met Office provider following a change in their API paths and header info.
|
- [weather] Fixed issue with the UK Met Office provider following a change in their API paths and header info.
|
||||||
|
- [core] add check for node_helper loading for multiple instances of same module (#3502)
|
||||||
|
|
||||||
## [2.28.0] - 2024-07-01
|
## [2.28.0] - 2024-07-01
|
||||||
|
|
||||||
|
24
js/app.js
24
js/app.js
@ -9,6 +9,7 @@ const Log = require("logger");
|
|||||||
const Server = require(`${__dirname}/server`);
|
const Server = require(`${__dirname}/server`);
|
||||||
const Utils = require(`${__dirname}/utils`);
|
const Utils = require(`${__dirname}/utils`);
|
||||||
const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`);
|
const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`);
|
||||||
|
const helperhash = {};
|
||||||
|
|
||||||
// Get version number.
|
// Get version number.
|
||||||
global.version = require(`${__dirname}/../package.json`).version;
|
global.version = require(`${__dirname}/../package.json`).version;
|
||||||
@ -175,14 +176,23 @@ function App () {
|
|||||||
|
|
||||||
const helperPath = `${moduleFolder}/node_helper.js`;
|
const helperPath = `${moduleFolder}/node_helper.js`;
|
||||||
|
|
||||||
let loadHelper = true;
|
// find out if helper was loaded before for this module
|
||||||
try {
|
// only load it once
|
||||||
fs.accessSync(helperPath, fs.R_OK);
|
let loadHelper = helperhash[moduleName] ? false : true;
|
||||||
} catch (e) {
|
|
||||||
loadHelper = false;
|
|
||||||
Log.log(`No helper found for module: ${moduleName}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// if this is the 1st time for this module, check for helper file
|
||||||
|
// otherwise, its already loaded, if found
|
||||||
|
if (loadHelper) {
|
||||||
|
try {
|
||||||
|
fs.accessSync(helperPath, fs.R_OK);
|
||||||
|
// indicte we found one to load for this module
|
||||||
|
helperhash[moduleName] = true;
|
||||||
|
} catch (e) {
|
||||||
|
loadHelper = false;
|
||||||
|
Log.log(`No helper found for module: ${moduleName}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the helper was found, AND needed 1st time
|
||||||
if (loadHelper) {
|
if (loadHelper) {
|
||||||
const Module = require(helperPath);
|
const Module = require(helperPath);
|
||||||
let m = new Module();
|
let m = new Module();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user