systemd 服务中,使用Requisite 定义依赖关系,被依赖服务未启动,但是当前单元的服务却成功启动

问题遇到的现象和发生背景

系统:ubuntu 18.04

systemd 服务中,使用Requisite 定义依赖关系,被依赖服务未启动,但是当前单元的服务却成功启动

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%

flask_app.service


[Unit]
Description=python web service(using gunicorn WSGI)
After=syslog.target network.target 
Requisite=mysql.service

[Service]
Type=simple
PIDFile=/data/project/xhxf/log/flask_app.pid
WorkingDirectory=/data/project/xhxf/
ExecStart=/usr/bin/gunicorn -b localhost:7071 app:app

[Install]
WantedBy=multi-user.target

执行了以下命令

systemctl daemon-reload

systemctl start flask_app.service
运行结果及详细报错内容

运行结果:

mysql 是未启动状态,日志内也会有显示当前服务未活跃

img

flask_app.service 却成功启动

img

按照官方文档说
However, if the units listed here are not started already, they will not be started and the starting of this unit will fail immediately
如果这里列出的单元尚未启动,则它们将不会启动,该单元的启动将立即失败。

实践和理论不匹配。想知道是哪里不对吗

Requires
单词拼错了

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^