More tweaks to improve stream reliability

This commit is contained in:
Tom Sightler
2024-07-04 21:19:05 -04:00
parent 60019ef527
commit 630eb36cd4

View File

@@ -54,10 +54,12 @@ stop() {
mosquitto_pub -i "${client_id}_pub" -L "mqtt://127.0.0.1:51883/${command_topic}" -m "OFF"
# Send kill signal to monitor script and wait for it to exit
local pids=$(jobs -pr)
# local pids=$(pgrep -f "monitor-stream.sh ${1} ${2} ${3} ${4}" | grep -v ^$$\$)
local pids=$(pgrep -f "monitor-stream.sh ${1} ${2} ${3} ${4}" | grep -v ^$$\$)
[ -n "$pids" ] && kill $pids
wait
sleep .1
eval exec {0..255}">&-"
sleep .1
cleanup
}
@@ -66,9 +68,7 @@ cleanup() {
rm -f /tmp/ring-mqtt-${device_id}.lock
# For some reason sleeping for 100ms seems to keep go2rtc from hanging
sleep .1
for fd in $(ls /proc/$$/fd); do
eval "exec $fd>&-"
done
eval exec {0..255}">&-"
exit 0
}
@@ -78,10 +78,10 @@ logger() {
}
# Trap signals so that the MQTT command to stop the stream can be published on exit
trap stop INT TERM
trap stop INT TERM EXIT
logger "Sending command to activate ${type} stream ON-DEMAND"
mosquitto_pub -i "${client_id}_pub" -L "mqtt://127.0.0.1:51883/${command_topic}" -m "ON-DEMAND ${rtsp_pub_url}"
nohup mosquitto_pub -i "${client_id}_pub" -L "mqtt://127.0.0.1:51883/${command_topic}" -m "ON-DEMAND ${rtsp_pub_url}" &
wait
cleanup