all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Should Guix Home daemonize Shepherd?
@ 2022-03-06 18:47 Kevin Boulain
  2022-03-12 17:49 ` Kevin Boulain
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Boulain @ 2022-03-06 18:47 UTC (permalink / raw)
  To: guix-devel

Hello,

I did a quick search in the tracker and the mailing list archives but
couldn't find a similar topic, apologies if this was already
discussed.

I was playing with Guix Home and I'm a bit surprised by how user
services are managed, especially the Shepherd itself.

Let's say I start from a clean state (I ran 'guix home reconfigure'
and rebooted the Guix machine) and I login via SSH:

$ ssh host
[...]
Service root has been started.
WARNING: Use of `load' in declarative module (#{ g56}#).  Add
#:declarative? #f to your define-module invocation.
Starting services...
Service example has been started.
$ exit

On the first login, the user's Shepherd is started and my 'example'
service is run. So far so good.

Now I login again:

$ ssh host
[...]
Starting services...
Service example has been started.
$ exit

The service is restarted again, meaning Shepherd and all the services
were killed when I logged out the first time. Is that expected?

Now, it's even weirder if I open two connections or more:

1$ ssh host
[...]
Starting services...
Service example has been started.
1$ # Don't exit this shell just yet.

2$ ssh host
2$ # Notice how the services weren't started again, I believe
$XDG_RUNTIME_DIR/on-first-login-executed is working as expected.

1$ exit # Now I logout from my first session.
2$ ps waux | grep $service # Nothing! The service has been killed
because I logged out from the first session.

Now, as long as the second session is kept open, the services won't be
restarted automatically, even if I open a third session. I need to
close all existing sessions and login again for the services to be
started.

Finally, I'm not sure Shepherd should share the terminal, it leads to
unfortunate situations like this (in addition to writing messages to
stdout like "Respawning $service", garbling any other process'
output):

$ ssh host
[...]
Starting services...
Service example has been started.
$ ^C # A single ^C will kill Shepherd, so I assume it wasn't properly
put in the background.
Exiting shepherd...
Service example has been stopped.
$ # I lost all my services :(

So, should the Shephered be daemonized when
$XDG_RUNTIME_DIR/on-first-login-executed is set?
I believe it would be a lot less surprising to users, unless the goal
was to prevent any lingering session in the first place.

---

For the record, I'm reproducing the above examples with this configuration:

;; guix home --dry-run reconfigure example.scm

(define-module (example)
  #:use-module (guix gexp)
  #:use-module (gnu home)
  #:use-module (gnu home services)
  #:use-module (gnu home services shepherd)
  #:use-module (gnu services)
  #:use-module (gnu packages base))

(define (example-shepherd-service _)
  (list
   (shepherd-service
    (documentation "Example service.")
    (provision '(example))
    (start #~(make-forkexec-constructor
              (list #$(file-append coreutils "/bin/sleep") "60")
              #:log-file (string-append (getenv "XDG_LOG_HOME")
"/example.log")))
    (stop #~(make-kill-destructor)))))

(define example-service-type
  (service-type
   (name 'example)
   (extensions
    (list
     (service-extension home-shepherd-service-type example-shepherd-service)))
   (default-value #nil)
   (description "Example service")))

(home-environment
 (services
  (list (service example-service-type))))


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-15 18:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-06 18:47 Should Guix Home daemonize Shepherd? Kevin Boulain
2022-03-12 17:49 ` Kevin Boulain
2022-05-06  8:07   ` Andrew Tropin
2022-05-15 13:20   ` Ludovic Courtès
2022-05-15 18:39     ` Kevin Boulain

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.