From systemd.unit(5)
, the option Requires=
means:
Configures requirement dependencies on other units. If this unit gets activated, the units listed here will be activated as well. If one of the other units gets deactivated or its activation fails, this unit will be deactivated.
I did a little experiment on that. I created 2 services: a.service
and b.service
:
# cat a.service
[Service]
ExecStart=/bin/false
# cat b.service
[Unit]
Requires=a.service
[Service]
ExecStart=/bin/sleep 1000
After I do
systemctl start b.service
I expected to see both a.service
and b.service
fail because a.service
fails with /bin/false
and b.service
fails with a.service
failure.
However, b.service
is running:
root@john-ubuntu:/etc/systemd/system# systemctl status a.service b.service
● a.service
Loaded: loaded (/etc/systemd/system/a.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-09-07 16:38:39 CST; 2s ago
Process: 1245 ExecStart=/bin/false (code=exited, status=1/FAILURE)
Main PID: 1245 (code=exited, status=1/FAILURE)
Sep 07 16:38:39 john-ubuntu systemd[1]: Started a.service.
Sep 07 16:38:39 john-ubuntu systemd[1]: a.service: Main process exited, code=exited, status=1/FAILURE
Sep 07 16:38:39 john-ubuntu systemd[1]: a.service: Unit entered failed state.
Sep 07 16:38:39 john-ubuntu systemd[1]: a.service: Failed with result 'exit-code'.
● b.service
Loaded: loaded (/etc/systemd/system/b.service; static; vendor preset: enabled)
Active: active (running) since Thu 2017-09-07 16:38:39 CST; 2s ago
Main PID: 1244 (sleep)
Tasks: 1
Memory: 88.0K
CPU: 696us
CGroup: /system.slice/b.service
└─1244 /bin/sleep 1000
Sep 07 16:38:39 john-ubuntu systemd[1]: Started b.service.
Did I miss something? Thanks.