版本号
1.8.0
什么问题
已在centos7.3下设置为系统自启动,详细方案如下:
=================================
1.建立系统服务文件
vi /lib/systemd/system/yapi.service
复制代码
[Unit]
Description=yapi
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/bin/bash -c 'nohup node /usr/local/nodejs/bin/my-yapi/vendors/server/app.js >/dev/null 2>&1 &'
ExecReload=/bin/bash -c 'kill -9 $(ps -ef|grep app.js|grep -v grep|awk '{print $2}');nohup node /usr/local/nodejs/bin/my-yapi/vendors/server/app.js >/dev/null 2>&1 &'
ExecStop=/bin/bash -c 'kill -9 $(ps -ef|grep app.js|grep -v grep|awk '{print $2}')'
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2.设置文件权限
chmod 754 yapi.service
3.服务重载
systemctl daemon-reload
4.启动服务
设置开机自启动
systemctl enable yapi.service
停止开机自启动:
systemctl disable yapi.service
启动服务:
systemctl start yapi.service
查看服务当前状态:
systemctl status yapi.service
重新启动服务:
systemctl restart yapi.service
1条答案
按热度按时间mrfwxfqh1#
补充几点:
/usr/local/nodejs/bin/my-yapi
这个路径要替换为你实际部署YApi的路径chmod 754 /lib/systemd/system/yapi.service