This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 28b9e82  [IOTDB-2824] fix stop-server.sh that wrongly kill process 
(#5378)
28b9e82 is described below

commit 28b9e822d21bd187e24f99cf1861bec268747169
Author: Jamber <[email protected]>
AuthorDate: Wed Mar 30 17:43:02 2022 +0800

    [IOTDB-2824] fix stop-server.sh that wrongly kill process (#5378)
    
    Co-authored-by: haiyi.zb <[email protected]>
---
 server/src/assembly/resources/sbin/stop-server.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/server/src/assembly/resources/sbin/stop-server.sh 
b/server/src/assembly/resources/sbin/stop-server.sh
index 5fb53f5..0cd069a 100755
--- a/server/src/assembly/resources/sbin/stop-server.sh
+++ b/server/src/assembly/resources/sbin/stop-server.sh
@@ -21,11 +21,18 @@
 
 IOTDB_CONF="`dirname "$0"`/../conf"
 rpc_port=`sed '/^rpc_port=/!d;s/.*=//' ${IOTDB_CONF}/iotdb-engine.properties`
-if type lsof > /dev/null; then
-  PID=$(lsof -t -i:${rpc_port})
+
+if  type lsof > /dev/null 2>&1 ; then
+  PID=$(lsof -t -i:${rpc_port} -sTCP:LISTEN)
+elif type netstat > /dev/null 2>&1 ; then
+  PID=$(netstat -anp 2>/dev/null | grep ":${rpc_port} " | grep ' LISTEN ' | 
awk '{print $NF}' | sed "s|/.*||g" )
 else
-  PID=$(ps ax | grep -i 'IoTDB' | grep java | grep -v grep | awk '{print $1}')
+  echo ""
+  echo " Error: No necessary tool."
+  echo " Please install 'lsof' or 'netstat'."
+  exit 1
 fi
+
 if [ -z "$PID" ]; then
   echo "No IoTDB server to stop"
   exit 1

Reply via email to