1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine srs script, use SIGKILL if SIGERM failed.

This commit is contained in:
winlin 2014-05-02 14:15:25 +08:00
parent e492180b78
commit 45da6b1ef9

View file

@ -108,21 +108,32 @@ stop() {
ok_msg "Stopping SRS(pid ${srs_pid})..."
# process exists, kill util stop
for((;;)); do
# process exists, try to kill to stop normally
for((i=0;i<30;i++)); do
load_process_info
if [[ 0 -eq $? ]]; then
kill -s SIGTERM ${srs_pid} 2>/dev/null
ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi
sleep 0.1
else
ok_msg "SRS stopped"
ok_msg "SRS stopped by SIGTERM"
# delete the pid file when stop success.
rm -f ${pid_file}
break;
fi
done
# process exists, use kill -9 to force to exit
load_process_info
if [[ 0 -eq $? ]]; then
kill -s SIGKILL ${srs_pid} 2>/dev/null
ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGKILL failed ret=$ret"; return $ret; fi
ok_msg "SRS stopped by SIGKILL"
else
# delete the pid file when stop success.
rm -f ${pid_file}
fi
sleep 0.1
return 0
}