example:
bar.service
:
[Unit]
After=foo.service
if foo.service isn't started correctly, will bar.service start? and what about if foo.service isn't a dependency of anything and will never start?
example:
bar.service
:
[Unit]
After=foo.service
if foo.service isn't started correctly, will bar.service start? and what about if foo.service isn't a dependency of anything and will never start?
You should view After=x
as meaning:
From man systemd.unit
:
Most importantly, for service units start-up is considered completed for the purpose of
Before=
/After=
when all its configured start-up commands have been invoked and they either failed or reported start-up success. Note that this does includesExecStartPost=
(orExecStopPost=
for the shutdown case).Note that those settings are independent of and orthogonal to the requirement dependencies as configured by
Requires=
,Wants=
,Requisite=
, orBindsTo=
. It is a common pattern to include a unit name in both theAfter=
andWants=
options, in which case the unit listed will be started before the unit that is configured with these options.
So that means:
bar.service
WILL start even if foo.service
ends with a failed state.
foo.service
is never activated, then bar.service
will stay waiting until foo.service
is activated somehow by other units.bar.service
will most likely eventually enter a failed state due to unmet dependency.JobTimeoutSec=
, JobRunningTimeoutSec=
. (See: How to change systemd service timeout value?)JobTimeoutAction=
to catch this case.
Requisite=foo.service
, thanks for correcting me @TooTea