An administrator wants to ensure that a custom service (myapp.service) starts only after the network is available and the PostgreSQL database service is running. Which systemd unit file directive should be used?
Trap 1: Requires=network.target postgresql.service
Requires= creates a dependency but does not guarantee start order; After= is needed.
Trap 2: Wants=network.target postgresql.service
Wants= is a weaker dependency, but still no ordering.
Trap 3: BindsTo=network.target postgresql.service
BindsTo= binds the service lifecycle to the listed units, but does not specify ordering.
- A
Requires=network.target postgresql.service
Why it fails: Requires= creates a dependency but does not guarantee start order; After= is needed.
- B
Wants=network.target postgresql.service
Why it fails: Wants= is a weaker dependency, but still no ordering.
- C
BindsTo=network.target postgresql.service
Why it fails: BindsTo= binds the service lifecycle to the listed units, but does not specify ordering.
- D
After=network.target postgresql.service
`After=` establishes ordering only, so myapp.service waits until both network.target and postgresql.service have activated before starting. This satisfies the stem's requirement that the custom service start only once the network is available and PostgreSQL is running, without implying a dependency that would pull those units in.