Deployment of Spring Boot project CentOS

In terms of Java, the current Spring Boot is relatively popular. After we have developed the project, how should we deploy it on Linux? How to bind the domain name after deployment?

1. First of all, let's take a look at the deployment of Linux. There may be various deployment methods. I will only talk about the jar deployment method I am currently using. If there is any inappropriate place, please enlighten me:

The jdk1.8+ environment has been installed by default. If the project name is [admin.jar], and the project deployment path is /opt/admin, let's write two shell scripts, one for starting the service and one for stopping Services, the codes are:

start.sh

#!/bin/bash
     
nohup java -jar /opt/admin/admin.jar &

For instructions on nohup and &, please go to https://my.oschina.net/u/166793/blog/1627570 for detailed reading

stop.sh

#!/bin/bash
     
PID=$(ps -ef | grep admin.jar | grep -v grep | awk '{ print $2 }')
     
if [ -z "$PID" ]
     
then
     
    echo Application is already stopped
     
else
     
    echo kill $PID
     
    kill $PID
     
fi

Note: If the server has multiple java processes, this script to stop the service will stop all java processes. Currently I have deployed only one

Create a new empty file vi nohup.out to record the project startup log

After the project is packaged, upload the rz command directly to the /opt/admin directory. If prompted [-bash: rz: command not found]

Install lrzsz:

# yum -y install lrzsz

If the current directory does not have executable permissions:

# chmod -R 777 admin

then execute the startup script

# ./start.sh

Then check the startup log

vi nohup.out

You can check whether the startup is successful.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325243091&siteId=291194637