MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Short script to monitor and restart your MMM-RTSPStreams

    General Discussion
    2
    2
    232
    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.
    • P
      p4lsec last edited by

      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

      1 Reply Last reply Reply Quote 0
      • BKeyport
        BKeyport Module Developer last edited by

        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.

        Remember the "E" in javascript is for "easy"

        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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy