Read the statement by Michael Teeuw here.
Restarting MM² when config.js file changes
-
This has been helpful for me, but I didn’t see it mentioned anywhere, so I thought I’d share. For anyone looking for a simple way to automatically restart your MM² when you change the
config.js
file:Note: This assumes you are using
pm2
to start the server, as described here: Auto Starting MagicMirror- Create a file in the same location as your
mm.sh
script calledmm.json
. - Paste the contents of this gist into the file (adjust if needed for your setup).
- Run
pm2 stop mm && pm2 delete mm
to stop & remove the current mm script. - Run
pm2 start mm.json
to restart MM. Now any time you changeconfig.js
,pm2
will automatically restart the process. - Run
pm2 save
to save your changes for the next reboot.
That’s it!
Originally inspired by: Restart Mirror?
- Create a file in the same location as your
-
For those that do a lot of testing, something I’ve found very useful as well: extract the
config.js
file out into it’s own git repo; then just switch between branches when you want to test something, that way you don’t break your “main” config file.cd ~ mkdir mmConfig cd mmConfig git init mv ~/MagicMirror/config/config.js ./config.js ln -s /home/pi/mmConfig/config.js /home/pi/MagicMirror/config/config.js git commit -am "Initial Commit" git checkout -b testing # Change and test config.js without fear of breaking it! # Use checkout -f master to switch back to your main branch
-
Hello !
I’ve followed your tutorial and it seems to work. For example my MM starts on boot.
But when my MM is open, if I press Alt+tab to open and modify my config.js file, nothing is happening (it is not restarting).
I don’t know why, do you have any idea ?Thank you !
Edit: After a reboot, this is working ! Ty
Edit2: There is a way to not completly rebooting it ? I mean doing the same thing as pressing CTRL + R, so the mirror reboots but stays on a black screen (instead of going back on the Desktop)
Edit3: If I do “pm2 stop mm.json” to stop the process and then start it again doing “pm2 start mm.json” then If I modify the config file, this is not working anymore -
Wow. Cool idea.
-
@shbatm Just want to tell you that I’ve googled this thread every single time I’ve setup a new mirror from scratch, and still love it. Thanks for making a post almost 6 years ago that still has all the info and works!
-
@looolz my install script sets up to monitor config.js. does sometimes…