[systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

Reindl Harald h.reindl at thelounge.net
Mon Jun 15 09:01:29 UTC 2020



Am 15.06.20 um 10:51 schrieb Kamal Rathi:
> Thanks Reindl for the response, but from the man page of systemd.service
> even oneshot is a kind of simple service as default is
> RemainAfterExit=no for simple.

simple:  long running processes
oneshot: expected to completly exit

this are completly different beasts and type simple has nothing to with
"the service is simple"

Behavior of oneshot is similar to simple; however, the service manager
will consider the unit up after the main process exits. It will then
start follow-up units. RemainAfterExit= is particularly useful for this
type of service

> But if we talk about the original problem that processes are killed even
> if ordering of services is there, .
> from what it seems that user.slice is killed before my services will
> shut down processes gracefully.
> I have tried also putting user.slice as After= dependency but result is
> the same.

what about just remove "RemainAfterExit" and look again?

can you answer the question why you did put that option at all into the
unit file and why do you add random options to your units like
"After=syslog.target systemd-user-sessions.service system.slice"

> On Mon, Jun 15, 2020 at 3:18 AM Reindl Harald <h.reindl at thelounge.net
> <mailto:h.reindl at thelounge.net>> wrote:
> 
> 
> 
>     Am 15.06.20 um 10:01 schrieb Kamal Rathi:
>     > Hi Team,
>     >
>     > I have two services which are dependent on each other and are working
>     > fine at boot up but at shutdown / reboot , the processes get killed as
>     > shutdown got initated.
>     >
>     > Services are running fine in particular order but processes got killed
>     > .I have enabled lingering on both users and changed confgiuration in
>     > logind.conf to KillUserProcesses=no but still issue is same 
>     >
>     > let me know if my configuration is faulty or what I have missed so
>     that
>     > shutdown should be graceful for services and processes will be
>     > shutdown with systemd custom service?
>     >
>     > I want first rdbms.service should be called and get process stopped
>     > before grid.services (it seems systemd are killing user.slices
>     > processes) and in startup-inverse should be followed .
>     > Please help
> 
>     i would start with thinking about why the useless "RemainAfterExit=yes"
>     is in a service with type=simple
> 
>     this is nice fot type=oneshot but makes no sense here when you want to
>     order things running long living processes
> 
>     RemainAfterExit=
>     Takes a boolean value that specifies whether the service shall be
>     considered active even when all its processes exited. Defaults to no.



More information about the systemd-devel mailing list