Systemd配置开机启动

  1. 创建并编写启动脚本
[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
  1. 设置允许后台启动 systemctl enable yapi.service

3.启动、停止、重启、查看状态

systemctl start yapi.service
systemctl stop yapi.service
systemctl restart yapi.service
systemctl status yapi.service
systemctl daemon-reload

参考文章:
CentOS7使用systemctl添加自定义服务
Linux 守护进程的启动方法

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容