[systemd-devel] Restarting service starts stopped dependants
Andrei Borzenkov
arvidjaar at gmail.com
Mon Feb 9 11:46:07 PST 2015
В Mon, 9 Feb 2015 19:25:34 +1100
Adam Zegelin <adam at instaclustr.com> пишет:
> Hi list,
>
> Is the following expected behaviour?
>
> Given services A, B, and C.
>
> C "Requires" A & B.
>
> All units are inactive.
>
> `systemctl restart A` activates C, which in turn activates B.
> Whereas `systemctl start A` activates A and only A. C and B are left
> inactive.
>
>
>
> I can understand that starting C should start both A and B as they
> are Required dependencies. But I can’t grasp why *restarting* A
> should start C, if C is stopped. And then by extension why B should
> start.
B is started because C is started so it is not relevant.
C is started probably due to logic "if A and C are running and you
restart A you should also restart C". I am not convinced it is the
right thing to do TBH, but well ...
Does patch below help?
diff --git a/src/core/transaction.c b/src/core/transaction.c
index b0b3d6b..8901119 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -1027,7 +1027,7 @@ int transaction_add_job_and_dependencies(
if (type == JOB_STOP || type == JOB_RESTART) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) {
- r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
+ r = transaction_add_job_and_dependencies(tr, type == JOB_RESTART ? JOB_TRY_RESTART : type, dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
More information about the systemd-devel
mailing list