mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
Merge pull request #2479 from buxxi/updatenotification-async-timeout
This commit is contained in:
commit
57174f09b9
@ -55,6 +55,7 @@ _This release is scheduled to be released on 2021-04-01._
|
|||||||
- Fix socket.io backward compatibility with socket v2 clients
|
- Fix socket.io backward compatibility with socket v2 clients
|
||||||
- 3rd party module language loading if language is English
|
- 3rd party module language loading if language is English
|
||||||
- Fix e2e tests after spectron update
|
- Fix e2e tests after spectron update
|
||||||
|
- Fix updatenotification creating zombie processes by setting a timeout for the git process
|
||||||
- Fix weather module openweathermap not loading if lat and lon set without onecall.
|
- Fix weather module openweathermap not loading if lat and lon set without onecall.
|
||||||
|
|
||||||
## [2.14.0] - 2021-01-01
|
## [2.14.0] - 2021-01-01
|
||||||
|
@ -14,32 +14,32 @@ module.exports = NodeHelper.create({
|
|||||||
|
|
||||||
start: function () {},
|
start: function () {},
|
||||||
|
|
||||||
configureModules: function (modules) {
|
configureModules: async function (modules) {
|
||||||
// Push MagicMirror itself , biggest chance it'll show up last in UI and isn't overwritten
|
// Push MagicMirror itself , biggest chance it'll show up last in UI and isn't overwritten
|
||||||
// others will be added in front
|
// others will be added in front
|
||||||
// this method returns promises so we can't wait for every one to resolve before continuing
|
// this method returns promises so we can't wait for every one to resolve before continuing
|
||||||
simpleGits.push({ module: "default", git: SimpleGit(path.normalize(__dirname + "/../../../")) });
|
simpleGits.push({ module: "default", git: this.createGit(path.normalize(__dirname + "/../../../")) });
|
||||||
|
|
||||||
var promises = [];
|
for (let moduleName in modules) {
|
||||||
|
|
||||||
for (var moduleName in modules) {
|
|
||||||
if (!this.ignoreUpdateChecking(moduleName)) {
|
if (!this.ignoreUpdateChecking(moduleName)) {
|
||||||
// Default modules are included in the main MagicMirror repo
|
// Default modules are included in the main MagicMirror repo
|
||||||
var moduleFolder = path.normalize(__dirname + "/../../" + moduleName);
|
let moduleFolder = path.normalize(__dirname + "/../../" + moduleName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log.info("Checking git for module: " + moduleName);
|
Log.info("Checking git for module: " + moduleName);
|
||||||
let stat = fs.statSync(path.join(moduleFolder, ".git"));
|
// Throws error if file doesn't exist
|
||||||
promises.push(this.resolveRemote(moduleName, moduleFolder));
|
fs.statSync(path.join(moduleFolder, ".git"));
|
||||||
|
// Fetch the git or throw error if no remotes
|
||||||
|
let git = await this.resolveRemote(moduleFolder);
|
||||||
|
// Folder has .git and has at least one git remote, watch this folder
|
||||||
|
simpleGits.unshift({ module: moduleName, git: git });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Error when directory .git doesn't exist
|
// Error when directory .git doesn't exist or doesn't have any remotes
|
||||||
// This module is not managed with git, skip
|
// This module is not managed with git, skip
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(promises);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
socketNotificationReceived: function (notification, payload) {
|
socketNotificationReceived: function (notification, payload) {
|
||||||
@ -54,36 +54,36 @@ module.exports = NodeHelper.create({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveRemote: function (moduleName, moduleFolder) {
|
resolveRemote: async function (moduleFolder) {
|
||||||
return new Promise((resolve, reject) => {
|
let git = this.createGit(moduleFolder);
|
||||||
var git = SimpleGit(moduleFolder);
|
let remotes = await git.getRemotes(true);
|
||||||
git.getRemotes(true, (err, remotes) => {
|
|
||||||
if (remotes.length < 1 || remotes[0].name.length < 1) {
|
if (remotes.length < 1 || remotes[0].name.length < 1) {
|
||||||
// No valid remote for folder, skip
|
throw new Error("No valid remote for folder " + moduleFolder);
|
||||||
return resolve();
|
|
||||||
}
|
}
|
||||||
// Folder has .git and has at least one git remote, watch this folder
|
|
||||||
simpleGits.unshift({ module: moduleName, git: git });
|
return git;
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
performFetch: function () {
|
performFetch: async function () {
|
||||||
var self = this;
|
for (let sg of simpleGits) {
|
||||||
simpleGits.forEach((sg) => {
|
try {
|
||||||
sg.git.fetch(["--dry-run"]).status((err, data) => {
|
let fetchData = await sg.git.fetch(["--dry-run"]).status();
|
||||||
data.module = sg.module;
|
let logData = await sg.git.log({ "-1": null });
|
||||||
if (!err) {
|
|
||||||
sg.git.log({ "-1": null }, (err, data2) => {
|
if (logData.latest && "hash" in logData.latest) {
|
||||||
if (!err && data2.latest && "hash" in data2.latest) {
|
this.sendSocketNotification("STATUS", {
|
||||||
data.hash = data2.latest.hash;
|
module: sg.module,
|
||||||
self.sendSocketNotification("STATUS", data);
|
behind: fetchData.behind,
|
||||||
}
|
current: fetchData.current,
|
||||||
|
hash: logData.latest.hash,
|
||||||
|
tracking: fetchData.tracking
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
} catch (err) {
|
||||||
});
|
Log.error("Failed to fetch git data for " + sg.module + ": " + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.scheduleNextFetch(this.config.updateInterval);
|
this.scheduleNextFetch(this.config.updateInterval);
|
||||||
},
|
},
|
||||||
@ -93,13 +93,17 @@ module.exports = NodeHelper.create({
|
|||||||
delay = 60 * 1000;
|
delay = 60 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
clearTimeout(this.updateTimer);
|
clearTimeout(this.updateTimer);
|
||||||
this.updateTimer = setTimeout(function () {
|
this.updateTimer = setTimeout(function () {
|
||||||
self.performFetch();
|
self.performFetch();
|
||||||
}, delay);
|
}, delay);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createGit: function (folder) {
|
||||||
|
return SimpleGit({ baseDir: folder, timeout: { block: this.config.timeout } });
|
||||||
|
},
|
||||||
|
|
||||||
ignoreUpdateChecking: function (moduleName) {
|
ignoreUpdateChecking: function (moduleName) {
|
||||||
// Should not check for updates for default modules
|
// Should not check for updates for default modules
|
||||||
if (defaultModules.indexOf(moduleName) >= 0) {
|
if (defaultModules.indexOf(moduleName) >= 0) {
|
||||||
|
@ -8,7 +8,8 @@ Module.register("updatenotification", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
||||||
refreshInterval: 24 * 60 * 60 * 1000, // one day
|
refreshInterval: 24 * 60 * 60 * 1000, // one day
|
||||||
ignoreModules: []
|
ignoreModules: [],
|
||||||
|
timeout: 1000
|
||||||
},
|
},
|
||||||
|
|
||||||
suspended: false,
|
suspended: false,
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -5840,9 +5840,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"simple-git": {
|
"simple-git": {
|
||||||
"version": "2.36.0",
|
"version": "2.36.2",
|
||||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.36.0.tgz",
|
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.36.2.tgz",
|
||||||
"integrity": "sha512-EJNaUgGYzBnQiyEkNZgbQSg76agbEDqlgHDr8DAXqV8xWvcefydbipye7YXtHMGbbEK998dcFezS8qF0sepZ5Q==",
|
"integrity": "sha512-orBEf65GfSiQMsYedbJXSiRNnIRvhbeE5rrxZuEimCpWxDZOav0KLy2IEiPi1YJCF+zaC2quiJF8A4TsxI9/tw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@kwsites/file-exists": "^1.1.1",
|
"@kwsites/file-exists": "^1.1.1",
|
||||||
"@kwsites/promise-deferred": "^1.1.1",
|
"@kwsites/promise-deferred": "^1.1.1",
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"node-ical": "^0.12.8",
|
"node-ical": "^0.12.8",
|
||||||
"rrule": "^2.6.8",
|
"rrule": "^2.6.8",
|
||||||
"rrule-alt": "^2.2.8",
|
"rrule-alt": "^2.2.8",
|
||||||
"simple-git": "^2.35.2",
|
"simple-git": "^2.36.2",
|
||||||
"socket.io": "^3.1.2",
|
"socket.io": "^3.1.2",
|
||||||
"valid-url": "^1.0.9"
|
"valid-url": "^1.0.9"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user