Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis of Spring Boot Jar package deployment script

Shulou Source: shulou.com Published: 2022-06-02 06:02:29 10月14日 Update

This article introduces you the example analysis of Spring Boot Jar package deployment script, the content is very detailed, interested friends can refer to, hope to be helpful to you.

When developing with Spring Boot, it can package the project as a Jar package for deployment, but our deployment environment is usually Linux, and every handwritten script is annoying, so I provide a simple script for deploying Spring Boot-generated Jar packages.

The content of the script is simple: drop the old process through the port kill and deploy the new Jar package.

#! / bin/bashport=8090jar_name= "Jar package name uploaded to the server" deployed_jar= "Jar package name deployed on the server" # Spring Boot profileactive_profile=real# backup directory backup_folder= "/ home/backup" # query the corresponding pidpid=$ according to the port number (netstat-nlp | grep: $port | awk'{print $7}'| awk-F "/" {print $1}'); # kill the corresponding process if [- n "$pid"] Then kill-9$ pid The fiecho "service has stopped" echo "backup files:" timestamp= `date "+% Y%m%d%H%M%S" `if [!-d "${backup_folder}"] then mkdir-p "${backup_folder}" fimv ${deployed_jar} ${backup_folder} / ${deployed_jar}-${timestamp} .jarmv ${jar_name} ${deployed_jar} nohup java-jar ${deployed_jar}-- spring.profiles.active=$ {active _ profile} & echo "Service started"

Knowledge point expansion:

Springboot's jar package deployment shell script

#! / bin/shID= `ps-ef | grep scada-server-report-smt-0.0.1-SNAPSHOT.jar | grep-v grep | awk'{print $2} '`echo $IDecho "-" if [- z $ID] Then echo "No killing process" else for id in $ID do kill-9$ id echo "killed $id" donefisleep 5nohup java-Xms512m-Xmx512m-jar scada-server-report-smt-0.0.1-SNAPSHOT.jar > / dev/null 2 > & 1 & echo "started successfully" example analysis of Spring Boot Jar package deployment script is shared here. I hope the above content can be of some help to you. You can learn more. If you think the article is good, you can share it for more people to see.

Tags: Script service content process instance instance analysis analysis name backup more server knowledge help good annoying success interest slogan boy buddy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Microsoft Huawei NVidia