MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Auto restart


  • Module Developer

    I’m wondering how this was done initially, and how to get it to happen again…

    When I installed a test copy of MagicMirror on my Test Raspberry, the software would auto-restart upon any changes to config.js. On my live copy, it does not do this… How was this done, and how can I get that back? I use PM2 to launch currently, although I don’t think it was being used on the test copy.

    Thanks!



  • @BKeyport this is a pm2 function, it ‘watches’ the file… we request that function, but its not working for some reason… it DOES work on mac, but nowhere else…

    could u open an issue on pm2 function not watching for config file changes…


  • Module Developer

    Hmm. interesting. I didn’t think the test copy was using PM2 when that was working. It stopped working when I set up PM2 the rest of the way per instructions…



  • There’s a REALLY simple way to do this using a script and a cron job.

    From the pi user, execute:

    sudo nano /bin/mmreload.sh
    

    Paste the following contents into that file:

    #!/bin/sh
    
    if [ /home/pi/MagicMirror/config/config.js -nt /home/pi/.pm2/pids/mm-0.pid ]; then
    /usr/bin/pm2 restart mm
    fi
    

    Save it (CTRL-X) and then give it execute permissions like this:

    sudo chmod +x /bin/mmreload.sh
    

    From the pi user, execute the following:

    crontab -e
    

    In the crontab file, add the following line:

    0,30 * * * * /bin/mmreload.sh  > /dev/null 2>&1
    

    Save the file (CTRL-X if you’re using nano).

    This will check the MM ‘pid’ file against the config.js file to see if the configuration file has been edited since the mirror was last started (it will check at the top and bottom of every hour). If the config file has been edited, it will restart MM and use the new configuration file.


Log in to reply