Skip to content

Commit

Permalink
feat(startup.sh): kill -9 if cvlc fails to exit
Browse files Browse the repository at this point in the history
  • Loading branch information
minhnhatnoe committed Jun 14, 2024
1 parent 276a56c commit 8c834a1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion image-toolkit/sbin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ vlc_restart_loop() {
dst=std{access=http,mux=ts,dst=:101} \
}"
echo "VLC exited, restarting in 3 seconds"

# Sleep to prevent CPU hogging and let the processes be killed in any order
sleep 3
done
Expand Down Expand Up @@ -100,9 +101,17 @@ webcam_stream_loop() {
echo "udevadm exited"
fi

echo "Sending SIGTERM to cvlc and udevadm"
kill $UDEVADM_PID $CVLC_PID || :

echo "VLC instance for webcam streaming exited, restarting in 3 seconds"
echo "Waiting for cvlc and udevadm to exit"
# timeout returns 124 if the command times out
timeout 3s wait -f $UDEVADM_PID $CVLC_PID; if [ $? -eq 124 ]; then
echo "Timeout waiting for cvlc and udevadm to exit, sending SIGKILL"
kill -9 $UDEVADM_PID $CVLC_PID || :
fi

echo "Restarting in 3 seconds"

# Sleep to prevent CPU hogging and let the processes be killed in any order
sleep 3
Expand Down

0 comments on commit 8c834a1

Please sign in to comment.