关于 Systemd
可以参考 阮一峰的网络日志 中的 《Systemd 入门教程:命令篇》
地址:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
备忘一下 Unit 的配置
- 在
/etc/systemd/system/下创建xxx.service文件
vim /etc/systemd/system/xxx.service- xxx.service的内容简易模板,其中
ExecStart根据实际情况指定xxx可执行文件或程序的运行命令
[Unit]Description=xxxDocumentation=https://github.com/xxxx/xxxxWants=network.targetAfter=network.target
[Service]Type=simpleDynamicUser=yesExecStart=/path/to/your/app/execRestart=alwaysRestartSec=3
[Install]WantedBy=multi-user.target- 注册及使用
# 装载xxx服务systemctl daemon-reload# 设置xxx开机启动systemctl enable xxx.service# 查看xxx状态systemctl status xxx.service# 启动xxxsystemctl start xxx.service# 重启xxxsystemctl restart xxx.service# 停止xxxsystemctl stop xxx.service