美文网首页
linux 制作系统服务

linux 制作系统服务

作者: _瑾_ | 来源:发表于2020-05-22 00:30 被阅读0次

模板 :template.service

[Unit]
Description="服务描述"
After=network.target

[Service]
Type=forking
Restart=no
KillMode=control-group
ExecStart="启动命令"
ExecStop="停止命令"
ExecReload="重载命令"

[Install]
WantedBy=multi-user.target

注意:
服务安装成功后,如果想要自启动: 需要配置 : chkconfig {serverName} on

centOS 环境

步骤

  • 根据模板文件创建一个服务文件,特别注意启动命令中如果是文件,需要注意文件中使用的相对路径.
  • 将服务文件 copy to : /usr/lib/systemd/system
  • 使用 systemctl daemon-reload重启载入一遍服务
  • 执行 systemctl start {serverName} 尝试启动下服务
  • 执行 systemctl status {serverName} 查看服务状态
  • 如果服务状态如下所示: 需要执行, systemctl enable {serverName}

hatom-py.service - hatom-server
Loaded: loaded (/usr/lib/systemd/system/***.service; disabled; vendor preset: disabled)
Active: inactive (dead)

相关文章

网友评论

      本文标题:linux 制作系统服务

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