This is an automated email from the ASF dual-hosted git repository.
neuyilan 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 80f36390a3 [IOTDB-3660] stop-datanode.sh/bat should only stop the
process of IoTDB (#6556)
80f36390a3 is described below
commit 80f36390a380105458158f36eba871b20e3d7ba2
Author: 任宇华 <[email protected]>
AuthorDate: Mon Jul 4 10:22:33 2022 +0800
[IOTDB-3660] stop-datanode.sh/bat should only stop the process of IoTDB
(#6556)
* fix stop-datanode.sh
* fix stop-datanode.sh
Co-authored-by: renyuhua <[email protected]>
---
.../src/assembly/resources/sbin/stop-datanode.sh | 26 +++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/server/src/assembly/resources/sbin/stop-datanode.sh
b/server/src/assembly/resources/sbin/stop-datanode.sh
index 27f9a0bef5..8dbf1d67fb 100644
--- a/server/src/assembly/resources/sbin/stop-datanode.sh
+++ b/server/src/assembly/resources/sbin/stop-datanode.sh
@@ -18,12 +18,32 @@
# under the License.
#
+DATANODE_CONF="`dirname "$0"`/../conf"
+rpc_port=`sed '/^rpc_port=/!d;s/.*=//'
${DATANODE_CONF}/iotdb-datanode.properties`
+
+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
+ echo ""
+ echo " Error: No necessary tool."
+ echo " Please install 'lsof' or 'netstat'."
+ exit 1
+fi
PIDS=$(ps ax | grep -i 'DataNode' | grep java | grep -v grep | awk '{print
$1}')
-if [ ! $PIDS ];then
+if [ -z "$PID" ]; then
echo "No DataNode to stop"
-else
+ exit 1
+elif [[ "${PIDS}" =~ "${PID}" ]]; then
+ kill -s TERM $PID
echo "Stop DataNode"
- jps | grep -w DataNode | grep -v grep | awk '{print $1}' | xargs kill
+else
+ echo "No DataNode to stop"
+ exit 1
fi
+
+
+