nginx部署jar包运行

2019-08-05  本文已影响0人  才不是小小喵
  1. 设置nginx 反向代理
    https://www.jianshu.com/p/19625bba68c1

  2. 设置.sh文件

#!/bin/bash

#删除老版本,生产环境是备份
date=`date +%Y%m%d`
cp -r /data/java/xxx-xxx-xxx-xxx.jar /data/backup/xxx-xxx-xxx-xxx_$date
#强制复制
cp -r /var/lib/jenkins/workspace/xxx-xxxx-xxx/web/target/*.jar /data/java/xxx-xxx-xxx-xxx.jar
#重启java
export JAVA_HOME=/usr/java/jdk1.8.0_191
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Port=8080
JarName=xxx-xxx-xxx-xxx.jar
LogsPatch=./logs_$Port
ID=`ps -ef | grep $Port | grep -v "grep" | awk '{print $2}'`
echo $ID  
echo "---------------"  
for id in $ID
do
kill -s 9 $id
echo "killed $id"  
done
echo "---------------"  

rm -rf $LogsPatch
mkdir $LogsPatch

export LANG=zh_CN.UTF-8

set -m 

nohup java -jar -Dlogging.path=$LogsPatch  $JarName>$LogsPatch/catlina.out 2>&1 &

sleep 10

上一篇下一篇

猜你喜欢

热点阅读