Skip to content

Commit

Permalink
scripts: fix nebd-daemon may stop failed
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-hanqing authored and YunhuiChen committed Nov 5, 2020
1 parent 6ad8fe7 commit 04d695d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions nebd/nebd-package/usr/bin/nebd-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ daemonLog=${baseLogPath}/nebd-server-daemon.log
consoleLog=${baseLogPath}/nebd-server-console.log

function get_nebd_server_pid() {
local tmp=`ps -ef | grep nebd-server | grep -v grep | grep -v daemon | awk '{print $2}'`
local tmp=`pidof nebd-server`
echo $tmp
}

Expand Down Expand Up @@ -146,6 +146,27 @@ function stop() {
then
echo "stop may not success!"
else
# wait 3s
retry_times=0
while [ $retry_times -le 3 ]
do
((retry_times=$retry_times+1))
pidof nebd-server > /dev/null 2>&1
if [ $? -eq 0 ]
then
sleep 1
else
break
fi
done

pidof nebd-server > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "nebd-server still exists after 3s, now kill it with SIGKILL"
kill -9 `pidof nebd-server`
fi

echo "nebd-server exit success!"
echo "daemon exit success!"
fi
Expand All @@ -170,7 +191,7 @@ function restart() {

if [ $old_pid == $new_pid ]
then
echo "restart nebd-server may failed, try kill -9 nebd-server"
echo "restart nebd-server may failed, now kill it with SIGKILL"
kill -9 $old_pid
fi
}
Expand Down

0 comments on commit 04d695d

Please sign in to comment.