From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9164 invoked from network); 17 Oct 2022 17:50:14 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 17 Oct 2022 17:50:14 -0000 Received: (qmail 30652 invoked by uid 89); 17 Oct 2022 17:50:39 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 30645 invoked from network); 17 Oct 2022 17:50:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antonovs.family; s=20200215; t=1666029003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=GvyQJ48XwpZRmBNk+LmMdxWIM/jLxJHFp+lN++8rk5s=; b=z5K5Q4+ywrtTyRJDIC/ke51fP0t4YHfxj1Ugi3DVfjVDVsE2ZadY6NOvFerSjnpBkmNCpn PPO9HsFMUT5/U0iW6ofx6ZsN3ssmSQ1n8RkV3SeFfvrYZqOUY8gzWFZbnvJuklyesFCiZE r3TyKGw48+FiENh89uiSLrhge+5NITQ= Date: Mon, 17 Oct 2022 10:50:34 -0700 From: Ihor Antonov To: supervision@list.skarnet.org Subject: s6-rc as user service manager Message-ID: <20221017175034.jmwoagcwrd6k4j2r@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Kicking off another thread because it is slightly different from UX related questions. I am trying to get s6-rc set up as a user service manager (similar how systemd allows user's to manage their own services with systemctl --user start bla). This is useful for example for starting user's dbus, pipewire, xdg-desktop-portal services, and other stuff that is strictly user related. This usecase is geared towards a desktop/laptop. There are number of challengers that I am facing with this task and I am not sure how to best solve. I will try to explain those as a set of scenarios as I amnot yet sure how make it more systematic: # Scenario 1 It is clear that in the very beginning we have to start svscan on an empty dir, then run s6-rc-init on it. Lets's assume svscan dir is tmpfs and is empty when machine boots. User's shell is configured in such way that a new login shell spawns s6-svscan on a scan dir and then runs s6-rc-init. Then necessary services can be started. User starts their computer,logs in, uses s6-rc to start services and everything is fine. (or is it?) # Scenario 2 User logs out their session. Svscan process dies with the login shell that spawned it. All services supervised by svscan die too. If machine is shutting down then we don't care, but it would've been nice to shut down serices in reverse dependency order. But machine is not shutting down and user logs in again. The Scandir is not empty, it contains all the links to services that were previously orchestrated with s6-rc. Login shell spawns svscan process on a scandir and all services start up immediately, out of order, and therfore some of them fail. Oneshot service that were intdended to be "once per boot" may run again too. This is a problem. # Scenario 3 A user is logged in on tty1, presses CTRL-ALT-F2 and switches to tty2 and logs in again. A login shell tries to run svscan on a scandir, svscan fail with error that another process is already running there. Same happens with s6-rc-init. There is s6-svok that tests if a service dir is supervised, but there are no similar test tools for scandir and live dir. Login shell can ignore errors, but this is bad practice since an error might happen in other legitimate situation. # Scenario 4 User has 2 login shells available, tty1 and tty2. User logs out of tty1 and svscan process spawned by tty1 login shell dies, leaving session on tty2 without neccessary services. # Problems summary - Login shell doesn't seem like a good place for user's service manager. What is a good place then? - How to solve "Run service manager once per user"? Such that service manager is spawned with the first login and exits correctly with the last login? - Is the amount of login shells a good measure for user's activity? Are the other cases when service manager is needed on a desktop machine? Like when we have 0 login shells but we need user's service manager? - Minor: a test utility for svscan dir would be nice - Minor: a test utility for live dir would be nice Checking lock files from shell is not fun and not reliable too