You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/04/14 08:11:20 UTC

[incubator-inlong] branch master updated: [INLONG-3692][Agent] Refactor the stop logic (#3693)

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

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new a4fbc66b3 [INLONG-3692][Agent] Refactor the stop logic (#3693)
a4fbc66b3 is described below

commit a4fbc66b34eb30a5ba7c4de1ebb5cd374edf8498
Author: dockerzhang <do...@apache.org>
AuthorDate: Thu Apr 14 16:11:14 2022 +0800

    [INLONG-3692][Agent] Refactor the stop logic (#3693)
---
 inlong-agent/bin/agent.sh | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/inlong-agent/bin/agent.sh b/inlong-agent/bin/agent.sh
index b5317864e..4e7b0c046 100755
--- a/inlong-agent/bin/agent.sh
+++ b/inlong-agent/bin/agent.sh
@@ -20,7 +20,6 @@ BASE_DIR=$(dirname $0)/..
 
 source $BASE_DIR/bin/agent-env.sh
 CONSOLE_OUTPUT_FILE="$LOG_DIR/agent-out.log"
-PID_FILE="$BASE_DIR/.agent.run.pid"
 
 function help() {
     echo "Usage: agent.sh {status|start|stop|restart}" >&2
@@ -32,16 +31,11 @@ function help() {
 }
 
 function running(){
-	if [ -f "$PID_FILE" ]; then
-		pid=$(cat "$PID_FILE")
-		process=$("$JPS" | grep "$pid" | grep -v grep)
-		if [ "$process" == "" ]; then
-	    	return 1;
-		else
-			return 0;
-		fi
+	process=$("$JPS" | grep "AgentMain" | grep -v grep)
+	if [ "$process" == "" ]; then
+	  	return 1;
 	else
-		return 1
+		return 0;
 	fi
 }
 
@@ -52,8 +46,6 @@ function start_agent() {
 		exit 1
 	fi
 	nohup $JAVA $AGENT_ARGS org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
-  echo $! > $PID_FILE
-  chmod 755 $PID_FILE
 }
 
 # stop agent
@@ -63,7 +55,7 @@ function stop_agent() {
 		exit 1
 	fi
 	count=0
-	pid=$(cat $PID_FILE)
+	pid=$("$JPS" | grep "AgentMain" | grep -v grep | awk '{print $1}')
 	while running;
 	do
 	  let count=$count+1
@@ -77,7 +69,6 @@ function stop_agent() {
 	  sleep 6;
 	done
 	echo "Stop agent successfully."
-	rm $PID_FILE
 }
 
 # get status of agent