Springboot projects are packaged into jars, uploaded to the server, each time you need to tap commands to redeploy the project, which you can write to the script and run directly.
Startup script (start.sh):
CUR_PATH=$(cd "$(dirname "$0")"; pwd) echo "Current path: ${CUR_PATH}" /usr/lib/java-1.8.0/jdk1.8.0_161/bin/java -jar ${CUR_PATH}/***.jar
The red part of the code, which specifies the start of the JDK (the JDK configured by the environment variable in the server is 7, the project is based on spring boot 2.0 and requires 8.0 +) for the JDK), can be used directly.javaInstead.
***It is the name of its own project.
This startup mode is running at the current window, and it will stop running if it leaves the current window. If you want to run backstage, add it directly to the code.&。
Close script (stop.sh):
PID=$(ps -ef | grep ***.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill $PID kill $PID fi
Restart script (restart.sh):
echo stop application
source stop.sh
echo start application
source start.sh
Finally, emphasize, don’t forget to give the new.Sh file.Execution permissions。