Read the statement by Michael Teeuw here.
MMM-Remote-Control is NOT able to restart Magic Mirror
-
I am loving the MMM=Remote-Control module for its many abilities. I have verified that with the exception of ONE, all of my functions are operational. The ‘Restart MagicMirror’ does NOT work, and pops up this error. This does NOT appear to be related to the process name, which is mm. I verified that the Remote files call for this same process name, but just to be safe I ALSO added the following into the MagicMirror/config/config.js file for the Remote module under config: pm2ProcessName: “mm”,
This is what pops up in the browser of the Remote-Control when clicking on restart. I should also note that ‘pm2 restart mm’ works without issues.
{ "success": false, "status": "error", "reason": "PM2 not installed or unlinked", "info": { "code": "MODULE_NOT_FOUND", "requireStack": [ "/home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js", "/home/##USERNAME##/MagicMirror/js/app.js", "/home/##USERNAME##/MagicMirror/js/electron.js", "/home/##USERNAME##/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js", null ] } }
Here is what the logs of pm2 show after a restart of the MagicMirror is attempted. Note that shutdown and restart BOTH work with ZERO issues.
0|mm | [06.02.2024 14:52.55.198] [ERROR] Error: Cannot find module 'pm2' 0|mm | Require stack: 0|mm | - /home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js 0|mm | - /home/##USERNAME##/MagicMirror/js/app.js 0|mm | - /home/##USERNAME##/MagicMirror/js/electron.js 0|mm | - /home/##USERNAME##/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js 0|mm | - 0|mm | at node:internal/modules/cjs/loader:1084:15 0|mm | at Function.<anonymous> (node:electron/js2c/browser_init:2:116646) 0|mm | at Module._resolveFilename (/home/##USERNAME##/MagicMirror/node_modules/module-alias/index.js:49:29) 0|mm | at node:internal/modules/cjs/loader:929:27 0|mm | at Function._load (node:electron/js2c/asar_bundle:2:13327) 0|mm | at Module.require (node:internal/modules/cjs/loader:1150:19) 0|mm | at require (node:internal/modules/cjs/helpers:121:18) 0|mm | at Class.controlPm2 (/home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js:954:18) 0|mm | at Class.executeQuery (/home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js:697:22) 0|mm | at Class.socketNotificationReceived (/home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js:1112:26) 0|mm | at Socket.<anonymous> (/home/##USERNAME##/MagicMirror/js/node_helper.js:104:11) 0|mm | at Socket.emit (node:events:514:28) 0|mm | at Socket.emitUntyped (/home/##USERNAME##/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22) 0|mm | at /home/##USERNAME##/MagicMirror/node_modules/socket.io/dist/socket.js:704:39 0|mm | at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { 0|mm | code: 'MODULE_NOT_FOUND', 0|mm | requireStack: [ 0|mm | '/home/##USERNAME##/MagicMirror/modules/MMM-Remote-Control/node_helper.js', 0|mm | '/home/##USERNAME##/MagicMirror/js/app.js', 0|mm | '/home/##USERNAME##/MagicMirror/js/electron.js', 0|mm | '/home/##USERNAME##/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js', 0|mm | undefined 0|mm | ] 0|mm | }
Looking further into this, I found an error in my pm2 logs, but I don’t believe it to be pm2 itself that has the error, as I get the SAME error whether pm2 auto-starts the mm or if I use npm manually after stopping pm2.
##USERNAME##@raspberrypi:~/MagicMirror $ pm2 start mm [PM2] Applying action restartProcessId on app [mm](ids: [ 0 ]) [PM2] [mm](0) ✓ [PM2] Process successfully started ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 0 │ mm │ default │ N/A │ fork │ 24416 │ 0s │ 2 │ online │ 0% │ 2.5mb │ ##USERNAME## │ disabled │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ##USERNAME##@raspberrypi:~/MagicMirror $ ##USERNAME##@raspberrypi:~/MagicMirror $ ##USERNAME##@raspberrypi:~/MagicMirror $ pm2 logs [TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option) /home/##USERNAME##/.pm2/pm2.log last 15 lines: 0|mm | 0|mm | > magicmirror@2.26.0 start 0|mm | > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js 0|mm | 0|mm | [06.02.2024 13:46.18.922] [LOG] Starting MagicMirror: v2.26.0 0|mm | [06.02.2024 13:46.18.934] [LOG] Loading config ... 0|mm | [06.02.2024 13:46.29.832] [INFO] updatenotification: You are not using pm2
Here is the same output after manually starting
##USERNAME##@raspberrypi:~/MagicMirror $ npm run start > magicmirror@2.26.0 start > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js [06.02.2024 13:45.07.088] [LOG] Starting MagicMirror: v2.26.0 [06.02.2024 13:45.07.098] [LOG] Loading config ... [06.02.2024 13:45.13.961] [INFO] updatenotification: You are not using pm2
I noticed also that pm2 had a folder which was in my home directory, NOT in the MagicMirror director. I took my test plaftorm, killed pm2, removed it, then installed it again from within the MagicMirror directory. After the install I did a pm2 status and saw that the .pm2 directory was again outside of the MagicMirror directory, so I trust that is expected behavior.
-
@ZiggidyZ the pm2 error in remote control is a module packaging problem
it demands the library to be able to do the job, but didn’t install it (see package json does not list it as a dependency
do this
change to the module folder and donpm install pm2
then restart mm and try again
-
@sdetweil Thank you, that did the trick!! I really appreciate it!
-
I’ve created a PR to fix this :-)