You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/03/30 11:46:26 UTC

[iotdb] branch rel/0.13 updated: [To rel/0.13][IOTDB-2824] fix stop-server.sh that wrongly kill process (#5381)

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

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


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new 67a7cf8  [To rel/0.13][IOTDB-2824] fix stop-server.sh that wrongly kill process (#5381)
67a7cf8 is described below

commit 67a7cf8e5ae5fdbfbd0755a4bc3aa75364d165b3
Author: Jamber <ja...@sina.com>
AuthorDate: Wed Mar 30 19:45:19 2022 +0800

    [To rel/0.13][IOTDB-2824] fix stop-server.sh that wrongly kill process (#5381)
    
    Co-authored-by: haiyi.zb <ha...@alibaba-inc.com>
---
 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