In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian for you to introduce in detail "Linux editing start, stop and restart springboot jar package method", the content is detailed, the steps are clear, the details are handled properly, I hope that this article "Linux editor start, stop and restart springboot jar package method" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.
Preface
In springboot configuration files, the names of configuration files have their own meaning and purpose.
Dev development environment
Prod production environment (default)
Test test environment
Load the specified configuration file-- spring.profiles.active=prod
Springboot loads jar packages in the following ways
/ / start directly in the console, but the disadvantage is that the console closes and the project is closed. Java-jar bootdo.jar// can run in the background, but if shell is introduced, it will also hang java-jar/ bootdo-2.0.0.jar > bootdolog.file 2 > & 1 & / plus nohup, even if shell is introduced. Nohup java-jar / bootdo-2.0.0.jar > bootdolog.file 2 > & 1 &
explain
Nohup means permanent operation. & indicates running in the background
> represents where to redirect
1 represents stdout standard output, and the system default value is 1, so "> / dev/null" equals "1 > / dev/null"
2 indicates stderr standard error
Nohup. / mqnamesrv > / home/cxb/mqnamesrv.out 2 > & 1 & that is, standard output to mqnamesrv.out, then standard error output redirection is equivalent to standard output and output to the same file.
After starting successfully on the server in the following way, if reboot is involved, you need to query the process number through ps-ef | grep bootdo, then kill it through kill-s 9 ${pid} and restart again, which is troublesome.
Nohup java-jar / bootdo-2.0.0.jar > bootdolog.file 2 > & 1 &
It's okay to say once or twice, but if it's involved many times, it's a bit of a breakdown.
In this way, we can start (start), stop (stop) and restart (restart) by writing a shell script, which is convenient and efficient.
Create a wss.sh script in the custom directory and edit it as follows.
#! / bin/bash# can be replaced with your own execution program here. Other code does not need to change the app_name=websocketserver-0.0.1-snapshot.jar # instructions to prompt the input parameter usage () {echo "usage: sh script name. Sh [start | stop | restart | status]" exit 1} # check whether the program is running is_exist () {pid= `ps-ef | grep $app_name | grep-v grep | awk'{print $2}'`# return 1 if it does not exist Return 0 if [- z "${pid}"] Then return 1 else return 0 fi} # Startup method start () {is_exist if [$?-eq "0]; then echo" ${app_name} is already running. Pid=$ {pid}. " Else nohup java-jar / mnt/ssd1/project/websocket/$app_name > / mnt/ssd1/project/websocket/websocketserverlog.file 2 > & 1 & echo "${app_name} start success" fi} # stop method stop () {is_exist if [$?-eq "0]; then kill-9$ pid else echo" ${app_name} is not running "fi} # output running status status () {is_exist if [$?-eq" 0] Then echo "${app_name} is running. Pid is ${pid} "else echo" ${app_name} is not running. " Fi} # restart restart () {stop start} # according to the input parameters, select to execute the corresponding method. If you do not enter, execute the instructions case "$1" in "start") start;; "stop") stop;; "status") status;; "restart") restart;; *) usage;; esac
Configure the startup command on the red connector line.
After that, you can start, stop, and restart operations via wss.sh start | stop | restart.
Add to it
The difference between sh xxx.sh and. / xxx.sh
Sh xxx.sh does not need to have execution permission
. / xxx.sh requires execution permission, which can be granted through chmod + x xxx.sh
After reading this, the article "how to start, stop and restart the springboot jar package for Linux editors" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.