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 2023/07/21 09:10:30 UTC

[iotdb] branch master updated: [IOTDB-6077]: Stop script addition -f(#10637)

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 deecd3c58e2 [IOTDB-6077]: Stop script addition -f(#10637)
deecd3c58e2 is described below

commit deecd3c58e2efb1e2ef75df6b1b7e793b2bbfca1
Author: CritasWang <cr...@outlook.com>
AuthorDate: Fri Jul 21 17:10:24 2023 +0800

    [IOTDB-6077]: Stop script addition -f(#10637)
---
 .../src/assembly/resources/sbin/stop-confignode.sh | 27 +++++++++++++++++--
 .../src/assembly/resources/sbin/stop-datanode.sh   | 27 +++++++++++++++++--
 .../src/assembly/resources/sbin/stop-standalone.sh | 31 ++++++++++++++++++++--
 3 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.sh b/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.sh
index 5714a0007b1..c9467faec55 100644
--- a/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.sh
+++ b/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.sh
@@ -34,6 +34,24 @@ else
   exit 1
 fi
 
+force=""
+
+while true; do
+    case "$1" in
+        -f)
+            force="yes"
+            break
+        ;;
+        "")
+            #if we do not use getopt, we then have to process the case that there is no argument.
+            #in some systems, when there is no argument, shift command may throw error, so we skip directly
+            #all others are args to the program
+            PARAMS=$*
+            break
+        ;;
+    esac
+done
+
 PID_VERIFY=$(ps ax | grep -i 'ConfigNode' | grep java | grep -v grep | awk '{print $1}')
 if [ -z "$PID" ]; then
   echo "No ConfigNode to stop"
@@ -42,8 +60,13 @@ if [ -z "$PID" ]; then
   fi
   exit 1
 elif [[ "${PID_VERIFY}" =~ ${PID} ]]; then
-  kill -s TERM "$PID"
-  echo "Close ConfigNode, PID:" "$PID"
+  if [[ "${force}" == "yes" ]]; then
+    kill -9 "$PID"
+    echo "Force to stop ConfigNode, PID:" "$PID"
+  else
+    kill -s TERM "$PID"
+    echo "Stop ConfigNode, PID:" "$PID"
+  fi
 else
   echo "No ConfigNode to stop"
   exit 1
diff --git a/iotdb-core/datanode/src/assembly/resources/sbin/stop-datanode.sh b/iotdb-core/datanode/src/assembly/resources/sbin/stop-datanode.sh
index c472b68dbe8..cb253f1a1ed 100644
--- a/iotdb-core/datanode/src/assembly/resources/sbin/stop-datanode.sh
+++ b/iotdb-core/datanode/src/assembly/resources/sbin/stop-datanode.sh
@@ -21,6 +21,24 @@
 DATANODE_CONF="`dirname "$0"`/../conf"
 dn_rpc_port=`sed '/^dn_rpc_port=/!d;s/.*=//' ${DATANODE_CONF}/iotdb-datanode.properties`
 
+force=""
+
+while true; do
+    case "$1" in
+        -f)
+            force="yes"
+            break
+        ;;
+        "")
+            #if we do not use getopt, we then have to process the case that there is no argument.
+            #in some systems, when there is no argument, shift command may throw error, so we skip directly
+            #all others are args to the program
+            PARAMS=$*
+            break
+        ;;
+    esac
+done
+
 echo "Check whether the rpc_port is used..., port is" $dn_rpc_port
 
 if  type lsof > /dev/null 2>&1 ; then
@@ -42,8 +60,13 @@ if [ -z "$PID" ]; then
   fi
   exit 1
 elif [[ "${PID_VERIFY}" =~ ${PID} ]]; then
-  kill -s TERM "$PID"
-  echo "Stop DataNode, PID:" "$PID"
+  if [[ "${force}" == "yes" ]]; then
+    kill -9 "$PID"
+    echo "Force to stop DataNode, PID:" "$PID"
+  else
+    kill -s TERM "$PID"
+    echo "Stop DataNode, PID:" "$PID"
+  fi
 else
   echo "No DataNode to stop"
   exit 1
diff --git a/iotdb-core/node-commons/src/assembly/resources/sbin/stop-standalone.sh b/iotdb-core/node-commons/src/assembly/resources/sbin/stop-standalone.sh
index d588fe902e2..6c9af2761f1 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/stop-standalone.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/stop-standalone.sh
@@ -22,6 +22,25 @@ if [ -z "${IOTDB_HOME}" ]; then
   export IOTDB_HOME="`dirname "$0"`/.."
 fi
 
+
+force=""
+
+while true; do
+    case "$1" in
+        -f)
+            force="yes"
+            break
+        ;;
+        "")
+            #if we do not use getopt, we then have to process the case that there is no argument.
+            #in some systems, when there is no argument, shift command may throw error, so we skip directly
+            #all others are args to the program
+            PARAMS=$*
+            break
+        ;;
+    esac
+done
+
 if [ -f "$IOTDB_HOME/sbin/stop-confignode.sh" ]; then
   export CONFIGNODE_STOP_PATH="$IOTDB_HOME/sbin/stop-confignode.sh"
 else
@@ -36,5 +55,13 @@ else
   exit 0
 fi
 
-bash "$CONFIGNODE_STOP_PATH"
-bash "$DATANODE_STOP_PATH"
+
+
+if [[ "${force}" == "yes" ]]; then
+  echo "Force stop all nodes"
+  bash "$CONFIGNODE_STOP_PATH" -f
+  bash "$DATANODE_STOP_PATH" -f
+else
+  bash "$CONFIGNODE_STOP_PATH"
+  bash "$DATANODE_STOP_PATH"
+fi