美文网首页
Systemd配置开机启动

Systemd配置开机启动

作者: 哲人王 | 来源:发表于2019-11-20 16:08 被阅读0次
    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 守护进程的启动方法

    相关文章

      网友评论

          本文标题:Systemd配置开机启动

          本文链接:https://www.haomeiwen.com/subject/matolctx.html