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

Short script to monitor and restart your MMM-RTSPStreams



  • Here is a super short Python script that checks the status of your streams using pm2, then if it detects a stream is down, it restarts the streams. Not elegant, but it works.

    import os
    if "stopped" in os.popen("pm2 status | grep \"stopped\"").read():
        os.popen("pm2 start 1 2 3 4")
    

    I saved it as streamMonitor.py in my home directory. I run it once per minute using crontab. This is the entry I put in:

    * * * * * python3 ~/streamMonitor.py
    

    Here is the script in action:

    0_1576967342114_Screen Shot 2019-12-21 at 5.27.57 PM.png

    And here is the crontab job:

    0_1576967509955_Screen Shot 2019-12-21 at 5.31.45 PM.png s


  • Module Developer

    neat. Sadly, OMX had so much trouble getting the streams running, I had to switch to FFMPeg.

    If VLC would boot correctly under node (it won’t), I’d use that, but between syntax errors in the code and node.js not allowing VLC to run correctly, I can’t get it to work.


Log in to reply