具体内容请设置为自己项目的配置
1.1 编辑文件
vim /etc/systemd/system/cabinet.service
1
文件内容
如果项目依赖Mysql服务,可以在After添加对应的Mysql服务名称
[Unit]
Description=Cabinet Server
# 指定此服务单元文件依赖于 network.target 和 mysqld.service,即网络服务
After=network.target mysqld.service
[Service]
# 指定启动 Java 服务的工作目录
WorkingDirectory=/home/cabinet
# 指定启动 Java 服务的命令和参数
ExecStart=/usr/local/java/jdk1.8.0_321/bin/java -Xms256m -Xmx512m -jar /home/cabinet/zq-cabinet-parent-1.1-SNAPSHOT.jar &
[Install]
# 指定此服务单元文件应该在哪个目标单元下启动,multi-user.target 表示多用户目标
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
1.2 分别执行以下命令
systemctl daemon-reload
systemctl enable cabinet
systemctl start cabinet
systemctl status cabinet
1
2
3
4
2
3
4
出现 active(running) 就可以了
请登录后发表评论~~~
暂无数据