CentOS 7配置springboot项目开机自启动

实验环境

  • CentOS 7.8
  • jdk11.0.8

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
posted @ 2021-12-07 16:11  兜儿~  阅读(1004)  评论(0编辑  收藏  举报