Sample code for the ultra fast deployment script for Spring Boot application
- 2020-09-16 07:27:44
- OfStack
preface
This article mainly introduces the Spring Boot application speed deployment script related content, sharing for your reference and learning, the following words are not enough, let's have a look at the detailed introduction.
Deployment methods are as follows:
Create a new file, start.sh, under the pom.xml path
#!/bin/bash
#0 , delete the original log files
rm -f nohup.out
#1 , get what is running Spring Boot The application of pid
appPid=`netstat -ntlp | grep java | awk '{print $7}' | head -1 | grep '[0-9]\+' -o`
#2 , close the running Spring Boot application
kill -9 ${appPid}
#3 And from the git Pull up the latest code
git pull
#4 , the use of Maven Package the latest code
mvn clean package
#5 , background run new jar file
nohup java -jar target/*.jar &
#6 Rest, 3 seconds
sleep 3
#7 , print the latest log
tail -f nohup.out
Make the start. sh script executable
chmod a+x start.sh
Use the script, 1 line command to rebuild the application
./start.sh
supplement
How do I specify close the specified application?
#!/bin/sh
APP_NAME=video
appid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${appid} ]; then
echo 'Kill Process!'
kill -9 $appid
fi
conclusion