Spring Boot 2.0.0.M7 生产环境部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot 2.0.0.M7 生产环境部署相关的知识,希望对你有一定的参考价值。
springboot 生产环境
注意事项 1.去除不需要的 jar
开发工具jar:spring-boot-devtools
监控一定要做好权限控制或者去除
控制jar:spring-boot-starter-actuator
druid的监控
swagger的接口 3、打包,跳过测试
maven:cleanpackage -Dmaven.test.skip=true
脚本
#!/bin/sh ## chang hereSERVICE_DIR=/var/www/ctoeduSERVICE_NAME=blog-api-boot-jpa-data-0.0.1-SNAPSHOTSPRING_PROFILES_ACTIVE=dev ## java env export JAVA_HOME=/opt/jdk1.8export JRE_HOME=${JAVA_HOME}/jrecase "$1" in start) procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${procedure}" = "" ]; then echo "start ..." if [ "$2" != "" ]; then SPRING_PROFILES_ACTIVE=$2 fi echo "spring.profiles.active=${SPRING_PROFILES_ACTIVE}" exec nohup ${JRE_HOME}/bin/java -Xms128m -Xmx512m -jar ${SERVICE_DIR}/${SERVICE_NAME}\.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE} >/dev/null 2>&1 & echo "start success" else echo "${SERVICE_NAME} is start" fi ;; stop) procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${procedure}" = "" ]; then echo "${SERVICE_NAME} is stop" else kill -9 ${procedure} sleep 1 argprocedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${argprocedure}" = "" ]; then echo "${SERVICE_NAME} stop success" else kill -9 ${argprocedure} echo "${SERVICE_NAME} stop error" fi fi ;; restart) $0 stop sleep 1 $0 start $2 ;; *) echo "usage: $0 [start|stop|restart] [dev|test|prod]" ;; esac
执行脚本
./ctoedu.sh start
./ctoedu.sh stop ./ctoedu.sh start test ./ctoedu.sh start dev ./ctoedu.sh start prod
ps -ef | grep blog-api-boot-jpa-data-0.0.1-SNAPSHOT
tail -100f logs
以上是关于Spring Boot 2.0.0.M7 生产环境部署的主要内容,如果未能解决你的问题,请参考以下文章