- 创建并编写启动脚本
[Unit]
Description=自动化API测试平台
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
#这里选择simple模式
Type=simple
#必须使用命令的全量路径
ExecStart=/usr/bin/node /root/workspaces/yapi/vendors/server/app.js
#kill命令发送
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=120s
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
- 设置允许后台启动
systemctl enable yapi.service
3.启动、停止、重启、查看状态
systemctl start yapi.service
systemctl stop yapi.service
systemctl restart yapi.service
systemctl status yapi.service
systemctl daemon-reload