Type=在 ubuntu16.04 上 etc/systemd/system/redis.service 上的分叉工作失败

Type=forking work fail on etc/systemd/system/redis.service on ubuntu16.04

我的/etc/systemd/system/redis.服务是

# /etc/systemd/system/redis.service
[Unit]
Description=Redis Server
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
Type=notify
#Type=forking

[Install]
WantedBy=multi-user.target

工作正常。

但是当我将类型从 "notify" 更改为网络建议时 "forking" 我收到错误消息,无法重新启动或停止 redis.server

$systemctl restart redis
Job for redis.service failed because a timeout was exceeded. See "systemctl status redis.service" and "journalctl -xe" for details.

我们需要查看您的 redis.conf 文件才能确定,但​​根据 this default configuration fileredis-server 默认情况下不进行守护进程,这意味着 Type=forking 绝对不正确。 Type=notify 似乎是最好的选择,因为 redis 支持 systemd 的显式就绪通知;但是,这需要 supervised 选项,默认情况下显然也未启用该选项。所以您可能想将 --supervised systemd 添加到 ExecStart= 指令。