我的/etc/systemd/system/redis.service是
# /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
工作得很好。
但是当我将Type从“notify”更改为web建议“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 file,redis-server
默认不守护,这意味着Type=forking
肯定是不正确的。 Type=notify
似乎是最好的选择,因为redis支持systemd的显式就绪通知;但是,这需要supervised
选项,默认情况下显然也没有启用。所以你可能想把--supervised systemd
添加到ExecStart=
指令中。