[systemd-devel] Restarting service starts stopped dependants
Adam Zegelin
adam at instaclustr.com
Mon Feb 9 14:17:13 PST 2015
> On 10 Feb 2015, at 6:46 am, Andrei Borzenkov <arvidjaar at gmail.com> wrote:
>
> B is started because C is started so it is not relevant.
Yes, this is expected because B is a dependency of C. Starting C should start B.
I mentioned it because, to me, it was unexpected that /re/starting A caused B to start.
> 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 …
Restarting C as a result of restarting A is correct behaviour to me, but
only if C was already running.
A restart = stop + start in a single transaction, correct?
As such, `systemctl restart A` should:
- Stop A
- Stop C (if it’s running) as C can’t run without A (Requires=A)
- Start A
- Start C, but only if C was previously running.
Starting C only if it was running previously makes sense, because `start` is not
transitive.
> 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;
I will try. I note that TRY_RESTART “… does nothing if units are not running.” (systemctl(1)), which is perhaps the solution to the problem.
Regards,
Adam
More information about the systemd-devel
mailing list