I’m not sure what the benefit of PM2 is. In my mind if the mirror crashed the error will need to be fixed and the Pi rebooted. In the event of a power outage the Pi will reboot on its own. This is a simpler way to autostart MM2
In my case I’m running a 7" RPi touchscreen display connected to a RPi v3 running Raspbian Jessie via GPIO pins and the HDMI connector. I am supplying power to both the display and the RPi via a single 2.5v USB power supply. For me, I need to be aware of power consumption.
When I first started I installed PM2 and after some headaches I got it running. It seemed like overkill in my mind even without my need to watch out for power hungry daemons. I figured there must be an easier way. After a lot of searching and trying different things here is what I came up with. It’s very simple and doesn’t carry any of the overhead that PM2 does.
Here’s my solution
Create a text file that’s called mm.sh in the MagicMirror folder. Add the following lines to that file
DISPLAY=:0 npm start
Now save the file.
Right click on it and select Properties. Make sure its set as “executable by anyone” Now close the properties panel.
Create an empty file on your desktop call mm.desktop
open the file with your text editor and copy the following into it
Comment=This is my comment
If you’ve left everything as the defaults when installing MM2 you wont need to change anything.
Save this file and place a copy of it in
That’s it. Reboot and your mirror should load each time you reboot your Pi.
Definitely saves CPU usage thereby cutting down on power usage. There is also less to get “borked” up.
- It has been reported that this doesn’t work with Jessie Lite. This method depends on prior loading of startx
This didn’t work for me. Running Raspbian Jessie lite. There is no file /home/pi/.config/autostart
There is one in /home/pi/.config/lxsession/LDXE/autostart but that did not work either. Various googling says the proper way of autostarting scripts in Jessie is systemd but it is overly complicated and I haven’t been able to figure it out.
@Chiumanfu autostart is a folder. You want to drop the mm.desktop file into that folder. Haven’t tried Jessie light but don’t know why it shouldnt work.
It should have worked where you tried as well. POST the contents of your mm.desktop file
I used PM2 to manged the Motion process in my first mirror. That code was fairly unstable and would crash 2-3 times a day. PM2 was a decent solution for that problem.
Now, I use it mostly out of habit. It also makes restarting the mirror process easy instead of having to reboot the entire Pi.