正在显示
1 个修改的文件
包含
14 行增加
和
3 行删除
| @@ -108,21 +108,32 @@ stop() { | @@ -108,21 +108,32 @@ stop() { | ||
| 108 | 108 | ||
| 109 | ok_msg "Stopping SRS(pid ${srs_pid})..." | 109 | ok_msg "Stopping SRS(pid ${srs_pid})..." |
| 110 | 110 | ||
| 111 | - # process exists, kill util stop | ||
| 112 | - for((;;)); do | 111 | + # process exists, try to kill to stop normally |
| 112 | + for((i=0;i<30;i++)); do | ||
| 113 | load_process_info | 113 | load_process_info |
| 114 | if [[ 0 -eq $? ]]; then | 114 | if [[ 0 -eq $? ]]; then |
| 115 | kill -s SIGTERM ${srs_pid} 2>/dev/null | 115 | kill -s SIGTERM ${srs_pid} 2>/dev/null |
| 116 | ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi | 116 | ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi |
| 117 | sleep 0.1 | 117 | sleep 0.1 |
| 118 | else | 118 | else |
| 119 | - ok_msg "SRS stopped" | 119 | + ok_msg "SRS stopped by SIGTERM" |
| 120 | # delete the pid file when stop success. | 120 | # delete the pid file when stop success. |
| 121 | rm -f ${pid_file} | 121 | rm -f ${pid_file} |
| 122 | break; | 122 | break; |
| 123 | fi | 123 | fi |
| 124 | done | 124 | done |
| 125 | 125 | ||
| 126 | + # process exists, use kill -9 to force to exit | ||
| 127 | + load_process_info | ||
| 128 | + if [[ 0 -eq $? ]]; then | ||
| 129 | + kill -s SIGKILL ${srs_pid} 2>/dev/null | ||
| 130 | + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGKILL failed ret=$ret"; return $ret; fi | ||
| 131 | + ok_msg "SRS stopped by SIGKILL" | ||
| 132 | + else | ||
| 133 | + # delete the pid file when stop success. | ||
| 134 | + rm -f ${pid_file} | ||
| 135 | + fi | ||
| 136 | + | ||
| 126 | sleep 0.1 | 137 | sleep 0.1 |
| 127 | return 0 | 138 | return 0 |
| 128 | } | 139 | } |
-
请 注册 或 登录 后发表评论