mirror of
https://github.com/tsightler/ring-mqtt.git
synced 2025-09-26 21:01:12 +08:00
More tweaks to improve stream reliability
This commit is contained in:
@@ -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
|
Reference in New Issue
Block a user