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

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


The following commit(s) were added to refs/heads/master by this push:
     new 37d045a9e [INLONG-5272][Agent] Change agent.sh format (#5273)
37d045a9e is described below

commit 37d045a9e3ed46dfc3d1425b322b49eb93468df8
Author: Lucas <[email protected]>
AuthorDate: Tue Aug 2 10:19:06 2022 +0800

    [INLONG-5272][Agent] Change agent.sh format (#5273)
---
 inlong-agent/bin/agent.sh | 130 +++++++++++++++++++++++-----------------------
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/inlong-agent/bin/agent.sh b/inlong-agent/bin/agent.sh
index 4e7b0c046..b3fb4dcac 100755
--- a/inlong-agent/bin/agent.sh
+++ b/inlong-agent/bin/agent.sh
@@ -18,95 +18,95 @@
 
 BASE_DIR=$(dirname $0)/..
 
-source $BASE_DIR/bin/agent-env.sh
-CONSOLE_OUTPUT_FILE="$LOG_DIR/agent-out.log"
+source "${BASE_DIR}"/bin/agent-env.sh
+CONSOLE_OUTPUT_FILE="${LOG_DIR}/agent-out.log"
 
 function help() {
-    echo "Usage: agent.sh {status|start|stop|restart}" >&2
-    echo "       status:     the status of inlong agent"
-    echo "       start:      start the inlong agent"
-    echo "       stop:       stop the inlong agent"
-    echo "       restart:    restart the inlong agent"
-    echo "       help:       get help from inlong agent"
+  echo "Usage: agent.sh {status|start|stop|restart}" >&2
+  echo "       status:     the status of inlong agent"
+  echo "       start:      start the inlong agent"
+  echo "       stop:       stop the inlong agent"
+  echo "       restart:    restart the inlong agent"
+  echo "       help:       get help from inlong agent"
 }
 
-function running(){
-       process=$("$JPS" | grep "AgentMain" | grep -v grep)
-       if [ "$process" == "" ]; then
-               return 1;
-       else
-               return 0;
-       fi
+function running() {
+  process=$("$JPS" | grep "AgentMain" | grep -v grep)
+  if [ "${process}" = "" ]; then
+    return 1;
+  else
+    return 0;
+  fi
 }
 
 # start agent
 function start_agent() {
   if running; then
-               echo "agent is running."
-               exit 1
-       fi
-       nohup $JAVA $AGENT_ARGS org.apache.inlong.agent.core.AgentMain > 
/dev/null 2>&1 &
+    echo "agent is running."
+    exit 1
+  fi
+  nohup ${JAVA} ${AGENT_ARGS} org.apache.inlong.agent.core.AgentMain > 
/dev/null 2>&1 &
 }
 
 # stop agent
 function stop_agent() {
   if ! running; then
-               echo "agent is not running."
-               exit 1
-       fi
-       count=0
-       pid=$("$JPS" | grep "AgentMain" | grep -v grep | awk '{print $1}')
-       while running;
-       do
-         let count=$count+1
-         echo "Stopping agent $count times"
-         if [ $count -gt 10 ]; then
-                 echo "kill -9 $pid"
-             kill -9 $pid
-         else
-             kill $pid
-         fi
-         sleep 6;
-       done
-       echo "Stop agent successfully."
+    echo "agent is not running."
+    exit 1
+  fi
+  count=0
+  pid=$("$JPS" | grep "AgentMain" | grep -v grep | awk '{print $1}')
+  while running;
+  do
+    (( count++ ))
+    echo "Stopping agent $count times"
+    if [ "${count}" -gt 10 ]; then
+        echo "kill -9 $pid"
+        kill -9 "${pid}"
+    else
+        kill "${pid}"
+    fi
+    sleep 6;
+  done
+  echo "Stop agent successfully."
 }
 
 # get status of agent
 function status_agent() {
   if running; then
-               echo "agent is running."
-               exit 0
-       else
-         echo "agent is not running."
-         exit 1
-       fi
+    echo "agent is running."
+    exit 0
+  else
+    echo "agent is not running."
+    exit 1
+  fi
 }
 
 function help_agent() {
-    $JAVA $AGENT_ARGS  org.apache.inlong.agent.core.AgentMain -h
+  ${JAVA} ${AGENT_ARGS} org.apache.inlong.agent.core.AgentMain -h
 }
 
 command=$1
 shift 1
 case $command in
-    status)
-        status_agent $@;
-        ;;
-    start)
-        start_agent $@;
-        ;;
-    stop)
-        stop_agent $@;
-        ;;
-    restart)
-        $0 stop $@
-        $0 start $@
-        ;;
-    help)
-        help_agent;
-        ;;
-    *)
-        help;
-        exit 1;
-        ;;
-esac
\ No newline at end of file
+  status)
+    status_agent $@;
+    ;;
+  start)
+    start_agent $@;
+    ;;
+  stop)
+    stop_agent $@;
+    ;;
+  restart)
+    $0 stop $@
+    $0 start $@
+    ;;
+  help)
+    help_agent;
+    ;;
+  *)
+    help;
+    exit 1;
+    ;;
+esac

Reply via email to