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
50 lines of code to change 5 skin colors, includi...
0x00 Introduction WordPress is the most popular C...
Hello everyone, today we are going to learn about...
constraint Constraints ensure data integrity and ...
Usage of having The having clause allows us to fi...
This article records the installation tutorial of...
Sometimes you may encounter a situation where a S...
To facilitate the maintenance of MySQL, a script ...
It is standard for websites to enable SSL nowaday...
Table of contents 1. Query Optimization 1. MySQL ...
Method 1: Command line modification We only need ...
Debug branch During the normal development of a p...
In the process of designing a web page, designers...
Introduction: The configuration of Docker running...
To achieve the following goals: Mysql database wi...