Explorar o código

添加 agent 的配置文件和启动脚本

reghao %!s(int64=2) %!d(string=hai) anos
pai
achega
62cdadfddb
Modificáronse 4 ficheiros con 58 adicións e 0 borrados
  1. 7 0
      agent/bin/agent.json
  2. 24 0
      agent/bin/restart.sh
  3. 22 0
      agent/bin/shutdown.sh
  4. 5 0
      agent/bin/start.sh

+ 7 - 0
agent/bin/agent.json

@@ -0,0 +1,7 @@
+{
+  "manager": {
+    "host": "localhost",
+    "port": 4020
+  },
+  "heartbeatInterval": 5
+}

+ 24 - 0
agent/bin/restart.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+app_dir=`pwd`
+app_name='devops-agent.jar'
+
+pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
+echo "process id: "${pid}
+if [[ -z ${pid} ]];
+then
+  echo "process killed"
+else
+  kill -15 ${pid}
+fi
+
+echo "sleep 10s and wait process killed"
+sleep 10
+pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
+if [[ -z ${pid} ]];
+then
+  echo "${app_name} has killed, restart now"
+  nohup java -jar ${app_dir}"/"${app_name} ${app_dir}/agent.json > console.log 2>&1 &
+else
+  echo "process ${pid} not killed"
+fi

+ 22 - 0
agent/bin/shutdown.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+app_name='devops-agent.jar'
+
+pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
+echo "process id: "${pid}
+if [[ -z ${pid} ]];
+then
+  echo "process killed"
+else
+  kill -15 ${pid}
+fi
+
+echo "sleep 10s and wait process killed"
+sleep 10
+pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
+if [[ -z ${pid} ]];
+then
+  echo "${app_name} has killed"
+else
+  echo "process ${pid} not killed"
+fi

+ 5 - 0
agent/bin/start.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+app_dir=`pwd`
+app_name='devops-agent.jar'
+nohup java -jar ${app_dir}"/"${app_name} ${app_dir}/agent.json > console.log 2>&1 &