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

    1. Create a file in the same location as your mm.sh script called mm.json.
    2. Paste the contents of this gist into the file (adjust if needed for your setup).
    3. Run pm2 stop mm && pm2 delete mm to stop & remove the current mm script.
    4. Run pm2 start mm.json to restart MM. Now any time you change config.js, pm2 will automatically restart the process.
    5. Run pm2 save to save your changes for the next reboot.

    That’s it!

    Originally inspired by: Restart Mirror?



  • 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
    

Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.