Spring Boot 시작,정지,재 부팅,상태 스 크 립 트
알림 기능 이 있 습 니 다.
프로젝트 폴 더 에 스 크 립 트 를 잃 어 버 리 고 실행 권한 을 추가 하면 됩 니 다.
이 스 크 립 트 를 사용 하려 면 자바-jar 명령 전에
BUILD_ID=dontKillMe
를 추가 해 야 합 니 다.그렇지 않 으 면 젠 킨 스 는 프로 세 스 를 죽 일 것 입 니 다.참고:
https://stackoverflow.com/questions/39169457/how-to-tell-jenkins-not-to-kill-processes-after-successful-execution-of-job-in-m
스 크 립 트 유 지 는 github 에 있 습 니 다.필요 하 다 면 주목 할 수 있 습 니 다.
https://github.com/junbaor/shell_script/blob/master/spring-boot.sh
spring-boot.sh
#!/bin/bash
SpringBoot=$2
if [ "$1" = "" ];
then
echo -e "\033[0;31m \033[0m \033[0;34m {start|stop|restart|status} \033[0m"
exit 1
fi
if [ "$SpringBoot" = "" ];
then
echo -e "\033[0;31m \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[0;31m Usage: \033[0m \033[0;34m sh $0 {start|stop|restart|status} {SpringBootJarName} \033[0m
\033[0;31m Example: \033[0m
\033[0;33m sh $0 start esmart-test.jar \033[0m"
esac
Spring Boot 예제 튜 토리 얼 과 원본 코드 가 업로드 되 었 습 니 다:https://github.com/javastacks/spring-boot-best-practice
이상 은 Spring Boot 시작,정지,재 부팅,상태 스 크 립 트 의 상세 한 내용 입 니 다.Spring Boot 시작 스 크 립 트 에 대한 자 료 는 다른 관련 글 을 주목 하 십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[MeU] Hashtag 기능 개발➡️ 기존 Tag 테이블에 존재하지 않는 해시태그라면 Tag , tagPostMapping 테이블에 모두 추가 ➡️ 기존에 존재하는 해시태그라면, tagPostMapping 테이블에만 추가 이후에 개발할 태그 기반 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.