我的/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
工作正常。
但是当我将类型从“通知”更改为网络建议“ fork ”时 我收到错误,无法重新启动或停止 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
默认不做daemonize,也就是说Type=forking
肯定是不对的。 Type=notify
似乎是最好的选择,因为 redis 支持 systemd 的显式就绪通知;但是,这需要 supervised
选项,默认情况下显然也未启用该选项。因此,您可能希望将 --supervised systemd
添加到 ExecStart=
指令。
关于redis - Type=ubuntu16.04 上的 etc/systemd/system/redis.service 上的 fork 工作失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52325308/