码迷,mamicode.com
首页 > 其他好文 > 详细

脚本改造

时间:2018-11-09 16:06:31      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:bootstrap   starting   uil   tin   agent   started   使用   --   port   

##########################Jenkins脚本改造#############################

BUILD_ID=DONTKILLME
#服务名称
SNAME=yutang-study-center-api
NAME=study-center-api
SBAG=yutang-study-center-api-1.0.0-SNAPSHOT.jar
SPORT=9003
SNODE=01
SHELL_DIR=/home/yutang
####################
mv /data/service/${SNAME}/target/*  ${SHELL_DIR}/
rm -rf  /data/service/${SNAME}/*
cp -r  ${SHELL_DIR}/*  /data/service/${SNAME}/
rm -rf ${SHELL_DIR}/*
##########################
#cd  /data/service/${SNAME}/
#服务启动传参
#第一个参数为服务名称
#第二个参数为服务端口
#第三个参数为节点ID,{--spring.application.node=01}
#使用启动脚本,需要传入三个参数
#重启服务
sleep 10
/bin/bash /data/service/${SNAME}/restart.sh   ${SBAG} ${SPORT}  ${SNODE}  ${NAME}
##################Service启动脚本改造##################################

#!/bin/bash
#kill service pid and starting service
SERVICEname=$1
SERVICEport=$2
SERVICEnode=$3
SERVICENAME=$4
BASEDIR=/data/service
echo "#####################################"
echo "name:${SERVICEname}"
echo "port:${SERVICEport}"
echo "node:${SERVICEnode}"
echo "node:${SERVICENAME}"
echo "#####################################"





# delete service node
curl "http://192.168.2.153:9100/services/manager/remove?name=${SERVICENAME}&node=${SERVICEnode}"
sleep 10



#Stoping Service
pidlist=`ps -ef|grep ${SERVICEname}|grep -v "grep" | grep -v "restart.sh"  |grep -v "tail" |awk ‘{print $2}‘`
if [ "$pidlist" = "" ]
   then
       #echo "Not Find ServicePid"
       echo " "
else
  kill -9 $pidlist
fi





# Starting Service
echo "####################################################################"
echo "${SERVICEname} is Being started"

#running service

#nohup /data/server/jdk1.8.0_112/bin/java  -Xms300m -Xmx300m  -jar  ${SERVICEname} #--server.port=${SERVICEport}  --spring.application.node=${SERVICEnode}  > /data/service/logs/${SERVICEname}.log & 2>&1 &


nohup /data/server/jdk1.8.0_112/bin/java -Xms300m -Xmx300m -javaagent:/data/service/pinpoint-agent/pinpoint-bootstrap-1.8.0.jar -Dpinpoint.agentId=${SERVICENAME}-${SERVICEnode} -Dpinpoint.applicationName=${SERVICENAME}   -jar  ${BASEDIR}/yutang-${SERVICENAME}/${SERVICEname} --server.port=${SERVICEport}  --spring.application.node=${SERVICEnode}  > /data/service/logs/${SERVICEname}.log & 2>&1 &

sleep 20



#Detection service
Runpid=`ps -ef|grep ${SERVICEname}|grep -v "grep" | grep -v "restart.sh"  |grep -v "tail" |awk ‘{print $2}‘`
sleep 10
if [ "$Runpid" = "" ]
   then
       echo "####################################################################"
       echo "Not Find ServicePid"
       echo "ServiceNode ${SERVICEnode} Startup faild"
       echo "${SERVICEname} is Startup faild"
       echo "####################################################################"
       exit 1
else
       echo "####################################################################"
       echo "ServiceNode ${SERVICEnode} Startup success"
       echo "${SERVICEname} is Startup success"       
       echo "service start success"
       #rm -rf /home/yutang/*
       echo "####################################################################"
       exit 0
fi

脚本改造

标签:bootstrap   starting   uil   tin   agent   started   使用   --   port   

原文地址:https://www.cnblogs.com/ipyanthony/p/9934745.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!