• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Restarting MM² when config.js file changes

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 5 Posters 5.3k Views 6 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    shbatm Module Developer
    last edited by Jul 9, 2017, 7:57 PM

    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?

    L 1 Reply Last reply Jan 22, 2023, 6:23 PM Reply Quote 3
    • S Offline
      shbatm Module Developer
      last edited by Jul 9, 2017, 7:57 PM

      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
      
      1 Reply Last reply Reply Quote 0
      • W Offline
        William
        last edited by William Nov 28, 2018, 1:39 PM Nov 26, 2018, 4:23 PM

        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

        1 Reply Last reply Reply Quote 0
        • B Offline
          BKeyport Module Developer
          last edited by Nov 26, 2018, 4:46 PM

          Wow. Cool idea.

          The "E" in "Javascript" stands for "Easy"

          1 Reply Last reply Reply Quote 0
          • L Offline
            looolz @shbatm
            last edited by Jan 22, 2023, 6:23 PM

            @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!

            S 1 Reply Last reply Jan 22, 2023, 6:53 PM Reply Quote 0
            • S Away
              sdetweil @looolz
              last edited by Jan 22, 2023, 6:53 PM

              @looolz my install script sets up to monitor config.js. does sometimes…

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy