[systemd-devel] require=? to prevent premature session termination

Reindl Harald h.reindl at thelounge.net
Fri Oct 5 13:03:01 UTC 2018



Am 05.10.18 um 14:52 schrieb Ralf Sieger:
> my service needs to delay the stop of ssh during shutdown.
> New ssh connections while my service is still runnign must be accpted, too.
>  
> So far I was able to postpone the stop of ssh and allow new connections:
> [Unit]
> BindsTo=ssh.service getty.target
> After=ssh.service getty.target
>  
> [Service]
> Type=simple
> TimeoutStopSec=600
> ExecStart=/usr/local/bin/rbs
>  
> [Install]
> WantedBy=multi-user.target
>  
> The remaining problem is that upon shutdown/restart existing ssh users
> still get disconnected.
> How can I that postpone, too? or, better: what is the missing depdency?

well, when you say "After=ssh.service" you get started after ssh at boot
and since shutdown is the reverse order ssh is terminated before your
service

so i would just say "Before=ssh.service" instead "After=ssh.service" ,
in that case ssh connections are only accepted after your service is
started and ssh is not killed as long your service is running

you can have only one of both

it's impossible to decalre a different order at boot and at shutdown
becaus eit makes no sense - you express ordering meaning "x makes only
sense after y is started" and the logical consequence is that the
sutdown acts in reverse order

when you say "After=myqld" you wan't to get started after mysqld because
your service can't live wothout, so it amkes zero sense at shutdown kill
mysqld first and then your service, given it's a webserver depending on
a working database otherwise it would accept new client connections it
can't handle


More information about the systemd-devel mailing list