Preface In the springboot configuration file, the names of the configuration files have their own meanings and uses
Load the specified profile --spring.profiles.active=prod Springboot loads jar packages in the following ways: // Start directly in the console. The disadvantage is that the project will be closed when the console is closed. java -jar bootdo.jar // This method can run in the background, but if the shell is launched, it will also hang java -jar /bootdo-2.0.0.jar > bootdolog.file 2>&1 & // If nohup is added, it will not be affected even if the shell is exited. nohup java -jar /bootdo-2.0.0.jar > bootdolog.file 2>&1 & explain nohup means running permanently. & indicates background operation > represents where to redirect to 1 means stdout standard output, the system default value is 1, so 2 means stderr standard error After the server is successfully started in the following way, if it involves a restart, you need to query the process ID through nohup java -jar /bootdo-2.0.0.jar > bootdolog.file 2>&1 & It's okay if it happens once or twice, but if it happens multiple times, it will be a bit overwhelming. In this way, you can write a shell script to start (start), stop (stop), and restart (restart) operations in one step, which is convenient and efficient Create a wss.sh script in a custom directory and edit the content as follows. #!/bin/bash #This can be replaced with your own executable program. No other code needs to be changed APP_NAME=websocketserver-0.0.1-SNAPSHOT.jar #Instructions for use, used to prompt for parameter input usage() { echo "Usage: sh script name.sh [start|stop|restart|status]" exit 1 } # Check if the program is running is_exist(){ pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' ` # If it does not exist, return 1; if it does exist, return 0 if [ -z "${pid}" ]; then return 1 else return 0 fi } #Start 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 the corresponding method to execute. If no input is given, the method will be executed. Instructions for use case "$1" in "start") start ;; "stop") stop ;; "status") status ;; "restart") restart ;; *) usage ;; esac Configure the startup command in the row marked in red. After that, you can use Add Difference between sh xxx.sh and ./xxx.sh sh xxx.sh does not need to have execution permission ./xxx.sh needs to have execution permission, which can be granted via Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue implements irregular screenshots
>>: Solve the group by query problem after upgrading Mysql to 5.7
This article mainly introduces the example of rea...
1. Idea It only took 6 seconds to insert 1,000,00...
Table of contents About FastDFS 1. Search for ima...
This article mainly introduces an example of Vue ...
Table of contents 1. Preliminary preparation 1.1 ...
Table of contents Preface 1. Download MySQL from ...
Effect picture (the border color is too light, pu...
Table of contents 1. Build basic styles through E...
/******************** * Application of linked lis...
This article shares the specific code of vue echa...
Often, after a web design is completed, the desig...
The Document Object Model (DOM) is a platform, a ...
Reminder: Whether it is planning, designing, or de...
Table of contents When to use Structural branches...
Table of contents MyISAM and InnoDB Reasons for p...