go守护进程
将你的go应用运行为守护进程,这里介绍一个github包,跨平台,简单易用。
前提知识点
linux系统下注册为系统服务,实现守护进程运行,主要通过systemd实现。
- systemd是系统启动的第一个进程
- systemctl是管理systemd的工具
- systemctl常用来管理和监督常驻服务,确保其运行。 类似supervisor守护进程工具。
systemctl命令
- systemctl enable xxx.service 允许服务
- systemctl start xxx.service 启动服务
- systemctl stop xxx.service 停止服务
- systemctl disable xxx.service 不允许服务
github实现
这里介绍一个github包,跨平台,简单易用,https://github.com/kardianos/service