ContOs makes SpringBoot's jar into a system service

Upload the jar package to the directory you want

Such as /java/service/demo.jar

Go to the /etc/systemd/system directory

Create demo.service

The content is as follows

----------------------------------------------------

[Unit]
Description=wechat
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/usr/bin/java -jar /java/service/demo.jar
ExecStop=/bin/kill -15 $MAINPID

User=root
Group=root

[Install]
WantedBy=multi-user.target

---------------------------------------------------

systemctl start demo.service starts the service
systemctl enable boot self-start
systemctl disable to stop self-starting at boot
systemctl status View status
systemctl restart restarts the service


 

Guess you like

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