Commit 85e9a101 authored by Michal Sekletar's avatar Michal Sekletar Committed by Michal Schmidt
Browse files

systemd: added new dependency PartOf

This should address TODO item "new dependency type to "group" services
in a target". Semantic of new dependency is as follows. Once configured
it creates dependency which will cause that all dependent units get
stopped if unit they all depend on is stopped or restarted.  Usual use
case would be configuring in template unit file
and in [Install] section and enabling desired
number of instances. In this case starting one instance won't pull in
target but stopping or starting target(in case of WantedBy is properly
configured) will cause stop/start of all instances.
parent c37046cd
......@@ -441,6 +441,21 @@
<listitem><para>Configures dependency
on other unit. When systemd stops or
restarts unit listed here, stop or
restart is propagated to dependent
units. Note that this is one way
dependency and changes to dependent
units does not affect listed unit. If
something else is desired, please
use some other type of dependency.
......@@ -112,6 +112,7 @@ Unit.PropagatesReloadTo, config_parse_unit_deps, UNIT_PROPAG
Unit.PropagateReloadTo, config_parse_unit_deps, UNIT_PROPAGATES_RELOAD_TO, 0
Unit.ReloadPropagatedFrom, config_parse_unit_deps, UNIT_RELOAD_PROPAGATED_FROM, 0
Unit.PropagateReloadFrom, config_parse_unit_deps, UNIT_RELOAD_PROPAGATED_FROM, 0
Unit.PartOf, config_parse_unit_deps, UNIT_PART_OF, 0
Unit.RequiresMountsFor, config_parse_unit_requires_mounts_for, 0, offsetof(Unit, requires_mounts_for)
Unit.StopWhenUnneeded, config_parse_bool, 0, offsetof(Unit, stop_when_unneeded)
Unit.RefuseManualStart, config_parse_bool, 0, offsetof(Unit, refuse_manual_start)
......@@ -994,6 +994,18 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONSISTS_OF], i) {
r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
if (e)
if (type == JOB_RELOAD) {
......@@ -1610,7 +1610,8 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
int r, q = 0, v = 0, w = 0;
......@@ -75,12 +75,14 @@ enum UnitDependency {
/* Inverse of the above */
UNIT_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
UNIT_WANTED_BY, /* inverse of 'wants' */
UNIT_BOUND_BY, /* inverse of 'binds_to' */
UNIT_CONSISTS_OF, /* inverse of 'part_of' */
/* Negative dependencies */
UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment