实验环境
1.上传或从Nexus上拉取可运行的springboot项目包
java -jar /opt/myapp.service
2.配置nginx.service
2.1编辑/etc/systemd/system/myapp.service
[Unit]
Description=A Spring Boot application
After=syslog.target
[Service]
Type=forking
User=root
ExecStart=/usr/bin/java -jar /opt/estest.jar
SuccessExitStatus=143
Restart=always
RestartSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3. 常见操作
3.1 刷新systemd服务
systemctl daemon-reload
3.2 查看所有已启动的服务
systemctl list-units --type=service
3.3 启动、停止、重启服务
systemctl start myapp.service
systemctl stop myapp.service
systemctl restart myapp.service
3.4 开启/关闭开机自启动
systemctl enable myapp.service
systemctl disable myapp.service