Systems and protocols · Intermediate

systemd: ordering, dependencies and readiness

Interpret service units, dependencies and readiness signals without assuming that process creation means the application is ready.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. A unit is a managed object
  2. Work through an ordering example
  3. Make readiness explicit
  4. Operate state transitions deliberately
  5. Ask Logeia about this articleCheck your understanding

A unit is a managed object

systemd represents services, sockets and other managed objects as units. A service unit describes commands, execution environment and policies for startup, stopping and restart. The manager tracks dependencies and state rather than merely running a flat sequence of scripts. Successful process creation is still different from successful application behavior. A process can exist before it finishes initialization or before a required remote dependency becomes usable. Diagnose the unit state together with the application’s own readiness and errors instead of treating a running process as proof that every request can now succeed.

Work through an ordering example

If service A declares After=B.service, it specifies ordering when both units participate in a start transaction. It does not alone pull B into that transaction. Wants and Requires express additional dependency relationships and have different failure behavior. A web service configuration can therefore request ordering after a database without actually requesting that the database be started. Even when ordering is satisfied, the database may not yet meet the application’s readiness criteria. Separate dependency inclusion, ordering and useful readiness when explaining why a service began before a resource became usable.

Make readiness explicit

Service types such as simple, exec and notify define different startup semantics. A notify-capable service can tell the manager when it has reached its defined readiness point. This matters for programs with significant initialization: starting a process is not the same event as accepting useful work. Configuring Type=notify does not magically add notification support to a program that never sends the expected message. The service’s behavior and unit configuration must agree. Also specify what readiness means for the application, rather than assuming that one notification proves every downstream dependency is healthy forever.

Operate state transitions deliberately

Enabling a service configures how it is pulled into future starts; it is not identical to starting the process immediately. Restart policies also require thought about delays and start limits rather than an assumption that endless immediate retries are beneficial. Inspect unit status, exit codes, journal chronology and whether changed configuration has been reloaded. Automatic restart does not repair the underlying fault. Preserve enough evidence to locate failure in dependency resolution, command execution or initialization, and distinguish a recovering service from a process that repeatedly starts and dies without serving useful work.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Understand the systems behind the web · STEP 14

Choose a learning path