Subject: Re: [bug#30532] [PATCH] Shepherd: Terminate all services upon SIGTERM or SIGHUP

From: Carlo Zancanaro <[email-masked]>
Date: Fri, 02 Mar 2018 18:25:26 +1100

Hey Leo,

On Fri, Mar 02 2018, Leo Famulari wrote:
> I'd rather we address this use case as described previously, 
> with something like 'enable-linger'.

I've not used the enable-linger functionality of systemd, but 
after doing some reading, maybe it could work like this?

At boot-time we could start an instance of shepherd for each 
permitted user (maybe with a `lingering-user-service-type` which 
adds a shepherd service?). It loads ~/.config/shepherd/init.scm, 
and starts any services which are enabled. It also adds a 
pseudo-service "login", which allows a user to specify a 
dependency on there being a current user session (so shepherd can 
be told to start processes on login, and to terminate them on 
logout).

For users who don't have a `lingering-user-service-type` running, 
pid 1 will listen until they log-in and will start a shepherd 
instance for them on login, loading ~/.config/shepherd/init.scm. 
When they logout pid 1 will terminate their user shepherd instance 
(along with any services it started).

This will require a few more changes to shepherd before it can 
work, but does that sound like the sort of behaviour you want? 
Could you open a new bug about it?

Carlo