借用 systemctl service 管理服务
1、添加 systemctl service 配置,demoapp 为例:/etc/systemd/system/demoapp.service
[Unit]
Description=demoapp
After=syslog.target
[Service]
ExecStart=/usr/bin/java -jar /data/sss/demo/demoapp.jar
SuccessExitStatus=143
SuccessExitStatus=143
Restart=on-failure
[Install]
WantedBy=multi-user.target
2、通过 systemctl 指令操控服务:
systemctl enable demoapp
systemctl restart demoapp
systemctl stop demoapp
配置好后之后,服务更新的简单操作:
- 更新 jar 文件
- 运行
systemctl restart demoapp
即可