Read the statement by Michael Teeuw here.
Two Instances in PM2
-
@bhepler hi there.
Thank you for the instructions. I did exactly as you said. It has taken away the “mm” instance. I am left with only the MagicMirror one now. However. It will not boot Into mirror mode on start up, although I can see the CPU is being used, so I type pm2 stop MagicMirror and it shows that it has stopped. Only way I can get the mirror to show is by typing cd MagicMirror
Then in that directory I type npm start. It does a small load thing and then my mirror shows. How can I get it to how it should be without having to go into the mirror directory?
Thank you for your patience. Most appreciated! -
@shazglass - Hmm. I don’t know. It should be working normally at this point. Let’s try switching to the previous process. We’ll delete the one that the installer created, then add the one to your script.
First, we remove the existing process:
cd ~ pm2 delete MagicMirror pm2 save
Then we use your
mm.sh
script that you had earlier.pm2 flush pm2 start mm.sh pm2 save
At this point, your mirror should come up in about 30 seconds. If it does not, enter
pm2 log mm
and copy the results here. Be sure to use the forum markup tools to help format your log messages. -
@bhepler hithere
I did as per your instructions - except I dont know how to use the forum markup tool…so just copied and pasted.
I now dont have any instances running? I can only access my mirror if i go ino cd MagicMirror and then type npm install.pi@raspberrypi:~ $ pm2 stop all
[PM2] Applying action stopProcessId on app [all](ids: 0)
[PM2] MagicMirror ✓
┌─────────────┬──────┬─────────┬───┬─────┬────────┐
│ Name │ mode │ status │ ↺ │ cpu │ memory │
├─────────────┼──────┼─────────┼───┼─────┼────────┤
│ MagicMirror │ fork │ stopped │ 6 │ 0% │ 0 B │
└─────────────┴──────┴─────────┴───┴─────┴────────┘
Usepm2 show <id|name>
to get more details about an app
pi@raspberrypi:~ $ pm2 delete MagicMirror
[PM2] Applying action deleteProcessId on app [MagicMirror](ids: 0)
[PM2] MagicMirror ✓
┌──────┬──────┬────────┬───┬─────┬────────┐
│ Name │ mode │ status │ ↺ │ cpu │ memory │
└──────┴──────┴────────┴───┴─────┴────────┘
Usepm2 show <id|name>
to get more details about an app
pi@raspberrypi:~ $ pm2 save
[PM2] Saving current process list…
[PM2] Nothing to save !!!
[PM2] In this case we keep old dump file. To clear dump file you can delete it manually !
pi@raspberrypi:~ $ pm2 flush
[PM2] Flushing /home/pi/.pm2/pm2.log
[PM2] Logs flushed
pi@raspberrypi:~ $ pm2 start mm.sh
[PM2][ERROR] script not found : /home/pi/mm.sh
script not found : /home/pi/mm.sh
┌──────┬──────┬────────┬───┬─────┬────────┐
│ Name │ mode │ status │ ↺ │ cpu │ memory │
└──────┴──────┴────────┴───┴─────┴────────┘
Usepm2 show <id|name>
to get more details about an app
pi@raspberrypi:~ $ pm2 save
[PM2] Saving current process list…
[PM2] Nothing to save !!!
[PM2] In this case we keep old dump file. To clear dump file you can delete it manually !
pi@raspberrypi:~ $ pm2 start mm
[PM2][ERROR] script not found : /home/pi/mm
script not found : /home/pi/mm
┌──────┬──────┬────────┬───┬─────┬────────┐
│ Name │ mode │ status │ ↺ │ cpu │ memory │
└──────┴──────┴────────┴───┴─────┴────────┘
Usepm2 show <id|name>
to get more details about an app
pi@raspberrypi:~ $ pm2 log mm
[TAILING] Tailing last 15 lines for [mm] process (change the value with --lines option)
[PM2][ERROR] No file to stream for app [mm], exiting.
pi@raspberrypi:~ $ pm2 log MagicMirror
[TAILING] Tailing last 15 lines for [MagicMirror] process (change the value with --lines option)
[PM2][ERROR] No file to stream for app [MagicMirror], exiting.
pi@raspberrypi:~ $ -
I did find this in the cd MagicMirror???
pi@raspberrypi:~/MagicMirror $ pm2 log MagicMirror
[TAILING] Tailing last 15 lines for [MagicMirror] process (change the value with --lines option)
/home/pi/.pm2/logs/MagicMirror-out.log last 15 lines:
/home/pi/.pm2/logs/MagicMirror-error.log last 15 lines:
0|MagicMir | at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
0|MagicMir | at Function.Module._load (internal/modules/cjs/loader.js:498:3)
0|MagicMir | at Module.require (internal/modules/cjs/loader.js:598:17)
0|MagicMir | at require (internal/modules/cjs/helpers.js:11:18)
0|MagicMir | Error: ENOENT: no such file or directory, open ‘package.json’
0|MagicMir | at Object.fs.openSync (fs.js:660:18)
0|MagicMir | at Object.fs.readFileSync (fs.js:565:33)
0|MagicMir | at Object. (/home/pi/MagicMirror/js/app.js:15:32)
0|MagicMir | at Module._compile (internal/modules/cjs/loader.js:654:30)
0|MagicMir | at Object.Module._extensions…js (internal/modules/cjs/loader.js:665:10)
0|MagicMir | at Module.load (internal/modules/cjs/loader.js:566:32)
0|MagicMir | at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
0|MagicMir | at Function.Module._load (internal/modules/cjs/loader.js:498:3)
0|MagicMir | at Module.require (internal/modules/cjs/loader.js:598:17)
0|MagicMir | at require (internal/modules/cjs/helpers.js:11:18) -
@shazglass - Ah. Okay, easy enough.
You’re missing the
mm.sh
script. I’m not sure how you had this registered in pm2 earlier, but we can fix it. We’ll use nano to create a newmm.sh
file:cd ~ nano mm.sh
This will give you a blank screen with the nano options at the bottom. Enter the following lines:
cd ~/MagicMirror DISPLAY=:0 npm start
When you’re done, hit
ctl+o
to save the file and thenctl+x
to exit nano. Then just like you did earlier, make your script executable by enteringchmod +x mm.sh
Before we go any further, we need to test your script. From the command line, enter
./mm.sh
Your mirror should start after 30 seconds or so. Try this and report back with any errors and behaviors. Also, please use the markup commands when posting code and logs (follow this link for a quick tutorial).