systemd

##实例

###配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=uWSGI Emperor
After=syslog.target

[Service]
ExecStart=/root/uwsgi/uwsgi --ini /etc/uwsgi/emperor.ini
# Requires systemd version 211 or newer
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

保存为 /etc/systemd/system/emperor.uwsgi.service; 或保存为/usr/lib/systemd/system/emperor.uwsgi.service,然后 systemctl enable emperor.uwsgi.service,这将创建同等软链接。

###启动与关闭、重启动

1
2
3
4
systemctl start emperor.uwsgi.service
systemctl stop emperor.uwsgi.service
systemctl restart emperor.uwsgi.service
systemctl status emperor.uwsgi.service

参考:
阮一峰的网络日志>>Systemd 入门教程:命令篇
Linux运维笔记>>systemd详解
systemd详解
systemd.service
RuntimeDirectory= creates directory with wrong group if Group= is set