mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-23 05:20:03 +00:00
3rd party modules updater for updatenotification (#3150)
Added my (modified) updater main core into updatenotification default module Missing: callback display in MM² (i will code it after) new part of configuration added: ``` updates: [ // array of module update commands { // with embed npm script "MMM-Test": "npm run update" }, { // with "complex" process "MMM-OtherSample": "rm -rf package-lock.json && git reset --hard && git pull && npm install" }, { // with git pull && npm install "MMM-OtherSample2": "git pull && npm install" }, { // with a simple git pull "MMM-OtherSample3": "git pull" } ], updateTimeout: 2 * 60 * 1000, // max update duration updateAutorestart: false // autoRestart MM when update done ? ``` @khassel: i need your help I don't use docker, maybe you can help me for this: How can i check if MM² is running inside a docker ? (from MM² main core) Actually, I check if we use pm2 or not. I have to check if docker is used or not too last time you tell me: "you can't use updater with docker", so I want to check and deny any update if docker used --------- Co-authored-by: bugsounet <bugsounet@bugsounet.fr>
This commit is contained in:
committed by
GitHub
parent
3fe5ad4b3d
commit
203e8647d4
@@ -1,6 +1,7 @@
|
||||
const NodeHelper = require("node_helper");
|
||||
const defaultModules = require("../defaultmodules");
|
||||
const GitHelper = require("./git_helper");
|
||||
const UpdateHelper = require("./update_helper");
|
||||
|
||||
const ONE_MINUTE = 60 * 1000;
|
||||
|
||||
@@ -11,6 +12,7 @@ module.exports = NodeHelper.create({
|
||||
updateProcessStarted: false,
|
||||
|
||||
gitHelper: new GitHelper(),
|
||||
updateHelper: null,
|
||||
|
||||
async configureModules(modules) {
|
||||
for (const moduleName of modules) {
|
||||
@@ -28,6 +30,8 @@ module.exports = NodeHelper.create({
|
||||
switch (notification) {
|
||||
case "CONFIG":
|
||||
this.config = payload;
|
||||
this.updateHelper = new UpdateHelper(this.config);
|
||||
await this.updateHelper.check_PM2_Process();
|
||||
break;
|
||||
case "MODULES":
|
||||
// if this is the 1st time thru the update check process
|
||||
@@ -51,12 +55,22 @@ module.exports = NodeHelper.create({
|
||||
const repos = await this.gitHelper.getRepos();
|
||||
|
||||
for (const repo of repos) {
|
||||
this.sendSocketNotification("STATUS", repo);
|
||||
this.sendSocketNotification("REPO_STATUS", repo);
|
||||
}
|
||||
|
||||
if (this.config.sendUpdatesNotifications) {
|
||||
const updates = await this.gitHelper.checkUpdates();
|
||||
if (updates.length) this.sendSocketNotification("UPDATES", updates);
|
||||
const updates = await this.gitHelper.checkUpdates();
|
||||
|
||||
if (this.config.sendUpdatesNotifications && updates.length) {
|
||||
this.sendSocketNotification("UPDATES", updates);
|
||||
}
|
||||
|
||||
if (updates.length) {
|
||||
const updateResult = await this.updateHelper.parse(updates);
|
||||
for (const update of updateResult) {
|
||||
if (update.inProgress) {
|
||||
this.sendSocketNotification("UPDATE_STATUS", update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.scheduleNextFetch(this.config.updateInterval);
|
||||
|
Reference in New Issue
Block a user