Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the Spring Boot project script look like

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces what the Spring Boot project script is like, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

This script is used to manage the process status of the SpringBoot project. There is a prompt function. Drop the script into the project folder and add execution permissions.

If jenkins uses this script, you need to add BUILD_ID=dontKillMe before the java-jar command, or jenkins will kill the process.

SpringMushboot.shemaking raceme binapod bash

SpringBoot=$2

If ["$1" = ""]

Then

Echo-e "\ 033 [0trans31m did not enter the operation name\ 0m\ 033 [0trans34m {start | stop | restart | status}\ 033 [0m"

Exit 1

Fi

If ["$SpringBoot" = ""]

Then

Echo-e "\ 033 [0trans31m] No application name was entered\ 033 [0m"

Exit 1

Fi

Function start ()

{

Count= `ps-ef | grep java | grep $SpringBoot | grep-v grep | wc-l`

If [$count! = 0]; then

Echo "$SpringBoot is running..."

Else

Echo "Start $SpringBoot success..."

Nohup java-jar $SpringBoot > / dev/null 2 > & 1 &

Fi

}

Function stop ()

{

Echo "Stop $SpringBoot"

Boot_id= `ps-ef | grep java | grep $SpringBoot | grep-v grep | awk'{print $2}'`

Count= `ps-ef | grep java | grep $SpringBoot | grep-v grep | wc-l`

If [$count! = 0]; then

Kill $boot_id

Count= `ps-ef | grep java | grep $SpringBoot | grep-v grep | wc-l`

Boot_id= `ps-ef | grep java | grep $SpringBoot | grep-v grep | awk'{print $2}'`

Kill-9 $boot_id

Fi

}

Function restart ()

{

Stop

Sleep 2

Start

}

Function status ()

{

Count= `ps-ef | grep java | grep $SpringBoot | grep-v grep | wc-l`

If [$count! = 0]; then

Echo "$SpringBoot is running..."

Else

Echo "$SpringBoot is not running..."

Fi

}

Case $1 in

Start)

Start

Stop)

Stop

Restart)

Restart

Status)

Status

*)

Echo-e "\ 033 [0bot 31m Usage:\ 033 [0m\ 033 [0m\ 033 [0m 34m sh $0 {start | stop | restart | status} {SpringBootJarName}\ 033 [0m]

\ 033 [0ter31m Example:\ 033 [0m]

\ 033 [0ter33m sh $0 start esmart-test.jar\ 033 [0m "

The following image of esac is a partial screenshot of the pdf version. About how the Spring Boot project script is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report