Systemd
- github:
- 参考文档:
在wsl系统启用systemd
Example
配置文件一般存放在/etc/systemd/system/目录下
example.service
[Unit]
Description=Job that runs the foo daemon
After=network.target
Documentation=man:foo(1)
[Service]
Type=forking
Environment=statedir=/var/cache/foo
ExecStartPre=/usr/bin/mkdir -p ${statedir}
ExecStart=/usr/bin/foo-daemon --arg1 "hello world" --statedir ${statedir}
; 运行目录
WorkingDirectory=
[Install]
WantedBy=multi-user.target
添加到系统自启动项中:
$ systemctl enable example
列出所有服务
systemctl list-unit-files --type=service
学习范例
node_exporter的ansible剧本:
执行路径
执行路径默认是在 /
目录
[Service]
WorkingDirectory=/data/gateway
查看日志
journalctl -u scrapyd