1.安装maven
过程略
2.安装git
yum install git
3.打包
#!/bin/bash
. /etc/profile
export BASE_WORKSPACE=/data/project
export PROJECT_WORKSPACE=$BASE_WORKSPACE/businessplatform
cd $PROJECT_WORKSPACE
chmod -R 777 $PROJECT_WORKSPACE
git init
git rev-parse --is-inside-work-tree
git config remote.origin.url http://47.105.160.77/qdgd/businessplatform.git
git fetch --tags --progress -- http://47.105.160.77/qdgd/businessplatform.git +refs/heads/*:refs/remotes/origin/*
checkid=`git rev-parse refs/remotes/origin/lanjing^{commit}`
git config core.sparsecheckout
git checkout -f $checkid
cd $PROJECT_WORKSPACE
chmod -R 777 $PROJECT_WORKSPACE
mvn clean install -U -P prod
4.发送文件以及远程命令
#!/bin/bash
. /etc/profile
export BASE_WORKSPACE=/data/project
export REMOTE_WORKSPACE=root@192.16.36.133:/data/workspace
export LOCAL_WORKSPACE=/data/project/businessplatform
scp $LOCAL_WORKSPACE/base-service-center/target/base-service-center.jar $REMOTE_WORKSPACE/jars
ssh root@192.16.36.133 'bash -s' < $BASE_WORKSPACE/ssh/133/run-base.sh
5.命令
#!/bin/bash
. /etc/profile
export TOMCAT_APP_PATH=/data/workspace/base-service
export JARS_WORKSPACE=/data/workspace/jars
### base 函数
killTomcat()
{
pid=`ps -ef | grep -w "base-service-center" | grep -v 'grep\|tail\|less\|more'| awk '{print $2}'`
echo "pid=" $pid
if [ "$pid" != "" ] ; then
kill -9 $pid
rm -f /opt/testtomcat/pid
else
rm -f /opt/testtomcat/pid
fi
}
# 停tomcat
killTomcat
rm -f $TOMCAT_APP_PATH/base-service-center.jar
cp $JARS_WORKSPACE/base-service-center.jar $TOMCAT_APP_PATH/
rm -f $JARS_WORKSPACE/base-service-center.jar
cd $TOMCAT_APP_PATH
nohup java -jar -Ddubbo.protocol.port=18880 -Xms512m -Xmx1024m base-service-center.jar --port=18881 --server.port=18882 --xxl.job.executor.port=18886 >logs/base-service-center.log 2>&1 &