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.jsfile:Note: This assumes you are using
pm2to start the server, as described here: Auto Starting MagicMirror- Create a file in the same location as your
mm.shscript calledmm.json. - Paste the contents of this gist into the file (adjust if needed for your setup).
- Run
pm2 stop mm && pm2 delete mmto stop & remove the current mm script. - Run
pm2 start mm.jsonto restart MM. Now any time you changeconfig.js,pm2will automatically restart the process. - Run
pm2 saveto 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.jsfile 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…
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login