Exercise 2: Wants= vs. Requires= for a Database Dependency — Possible Solution ==================================================================== -- With Wants= -- -- -- Per the chapter's own definition, Wants= is a soft dependency: if -- the database fails to start, the service still proceeds to start -- normally anyway, per the chapter's own wording, "if the wanted unit -- fails to start, the wanting unit still proceeds normally." The -- service would come up regardless of the database's own success or -- failure -- which, for a service that genuinely CAN'T function -- without its database, would likely mean the service starts -- successfully from systemd's own point of view, but then fails or -- errors out on its own once it actually tries to connect to a -- database that was never actually running. -- With Requires= -- -- -- Requires= is a hard dependency: per the chapter's own definition, if -- the required unit (the database) fails to start, "systemd treats -- this unit's own startup as a failure too." The service itself would -- NOT be considered successfully started if its database dependency -- failed -- systemd would report the service's own startup as having -- failed, rather than letting it come up in a broken, database-less -- state. Requires= additionally means that if the database is later -- STOPPED while the service is running, systemd can stop the -- dependent service too, per the chapter's own description. -- Which is correct for a service that genuinely cannot function without its database -- -- -- Requires= is the correct choice here, using the chapter's own -- worked example directly -- the chapter itself names exactly this -- case ("Requires= its own database if it literally cannot function -- without one") as the appropriate use for the stricter dependency -- type, since Wants= would let the service come up in a state where -- it's reported as "running" by systemd while actually being -- completely non-functional underneath. WHY THIS WORKS AS AN ANSWER ------------------------------ This works through the concrete consequence of each choice specifically for a database-dependent service (Wants= letting it come up broken vs. Requires= correctly reporting failure), then explicitly ties the conclusion back to the chapter's own stated example rather than a generic restatement of the two definitions.