12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/bin/bash
- set -o nounset # 遇到没定义的变量报错后,终止继续执行脚本文件
- set -o errexit # 执行失败以后,终止继续执行脚本文件
- # 平滑关闭和启动 Spring Boot 应用
- # 给脚本增加执行权限
- # chmod +x start.sh
- # Jar包应用名称
- # ./bin/start.sh marketing-auth-server_test_20200514225829.jar
- # JAR_NAME=marketing-auth-server_test_20200514225829.jar
- # APPLICATION_NAME=marketing-auth-server
- JAR_NAME=$1
- APPLICATION_NAME=${JAR_NAME%%_*}
- # 应用启动环境
- SPRING_PROFILES_ACTIVE='dev'
- # 应用启动后日志输出目录
- LOG_PATH='./logs/log-info.log'
- JVM_OPTIONS='-Dloader.path=./lib'
- JAVA_OPTIONS=' --spring.profiles.active=dev --spring.config.location=file:./conf/ --logging.config=file:./conf/logback.xml'
- #JAVA_OPTS='-Xms128m -Xmx512m -XX:NewSize=128m -XX:MaxNewSize=512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -XX:NewRatio=2 -XX:MaxTenuringThreshold=8 -XX:+DisableExplicitGC'
- # 应用端口
- # SERVER_PORT='8080'
- # echo nohup java -jar $JAVA_OPTIONS $JAR_NAME --server.port=$SERVER_PORT --spring.profiles.active=$SPRING_PROFILES_ACTIVE > /dev/null &
- # nohup java -jar $JAVA_OPTIONS $JAR_NAME --server.port=$SERVER_PORT --spring.profiles.active=$SPRING_PROFILES_ACTIVE > /dev/null &
- echo "---------- ---------- 停止应用 ---------- ----------"
- . ./bin/stop.sh ${APPLICATION_NAME}
- echo "---------- ---------- 停止应用 ---------- ----------"
- echo -e "\n\n\n"
- echo "---------- ---------- 启动应用 ---------- ----------"
- echo '【'$APPLICATION_NAME'】服务正在启动... ...'
- # 非挂起方式启动应用,并且跟踪启动日志文件
- nohup java $JVM_OPTIONS -jar $JAR_NAME $JAVA_OPTIONS > /dev/null 2>&1 &
- # 将jar包启动对应的pid写入文件中,为停止时提供pid
- echo $APPLICATION_NAME '启动后的pid:' $!
- echo $! > ${APPLICATION_NAME}.pid
- sleep 5s
- echo "---------- ---------- 启动应用 ---------- ----------"
|