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:
parent
e492180b78
commit
45da6b1ef9
1 changed files with 14 additions and 3 deletions
|
@ -108,21 +108,32 @@ stop() {
|
||||||
|
|
||||||
ok_msg "Stopping SRS(pid ${srs_pid})..."
|
ok_msg "Stopping SRS(pid ${srs_pid})..."
|
||||||
|
|
||||||
# process exists, kill util stop
|
# process exists, try to kill to stop normally
|
||||||
for((;;)); do
|
for((i=0;i<30;i++)); do
|
||||||
load_process_info
|
load_process_info
|
||||||
if [[ 0 -eq $? ]]; then
|
if [[ 0 -eq $? ]]; then
|
||||||
kill -s SIGTERM ${srs_pid} 2>/dev/null
|
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
|
ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
else
|
else
|
||||||
ok_msg "SRS stopped"
|
ok_msg "SRS stopped by SIGTERM"
|
||||||
# delete the pid file when stop success.
|
# delete the pid file when stop success.
|
||||||
rm -f ${pid_file}
|
rm -f ${pid_file}
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
done
|
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
|
sleep 0.1
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue