Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch rtsp watchdog #338

Open
wants to merge 2 commits into
base: xf-data
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions etc/scripts/30-rtsp-watchdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
PIDFILE="/var/run/rtsp-watchdog.pid"

status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}

start()
{
echo "Starting RTSP Watchdog script..."
fang-rtsp-watchdog.sh </dev/null >/dev/null 2>&1 &
echo "$!" > "$PIDFILE"
}

stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill $pid || rm "$PIDFILE"
fi
}

if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
esac
fi
15 changes: 15 additions & 0 deletions usr/bin/fang-rtsp-watchdog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

echo "RTSP Watchdog script started"

while :
do
sleep 10
if pgrep -x "snx_rtsp_server" > /dev/null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have the 'problem' that it will start the RTSP server even if you manually stopped it.

Sorry for resurfacing this, but I implemented the exact same script before checking the open pull requests, and I had that issue.

Maybe you could check the existence of the /var/run/rtsp-server.pid file and check the enclosed PID?

then
echo "RTSP ON"
else
echo "RTSP OFF"
/media/mmcblk0p2/data/etc/scripts/20-rtsp-server start > /dev/null
fi
done