[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Invoking user shepherd; Was: Re: Defining *user* services in Guix
From: |
Ludovic Courtès |
Subject: |
Re: Invoking user shepherd; Was: Re: Defining *user* services in Guix |
Date: |
Tue, 13 Jun 2017 10:06:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Hello!
Danny Milosavljevic <address@hidden> skribis:
> For a real user shepherd, it would be nice if when I logged in twice using
> the same user account (without logging out in-between - so resulting in two
> sessions of that user) it would still only have one shepherd instance for
> that user account in total - and if that instance (and remaining user
> processes for that matter) went away only when I logged out from *all*
> sessions of that user.
>
> I thought I could fake that by just trying to invoke shepherd on each session
> start and have it fail on the second attempt - but apparently we will happily
> start an infinite number of shepherds for one user. Is that on purpose?
>
> The relevant place (in shepherd) is:
>
> (define (open-server-socket file-name)
> "Open a socket at FILE-NAME, and listen for connections there."
> (with-fluids ((%default-port-encoding "UTF-8"))
> (let ((sock (socket PF_UNIX SOCK_STREAM 0))
> (address (make-socket-address AF_UNIX file-name)))
> (false-if-exception (delete-file file-name)) ; <===== [dannym: WTF.
> Would it be better to try to connect first?]
> (bind sock address)
> (listen sock 10)
> sock)))
>
> Probably not good.
The ‘delete-file’ was to avoid EADDRINUSE but I wonder if it’s really a
good idea.
> Maybe better:
>
> (define (server-present? file-name)
> "Open a socket at FILE-NAME, and connect to the server, if any. Return #t
> if that worked."
> (with-fluids ((%default-port-encoding "UTF-8"))
> (let ((sock (socket PF_UNIX SOCK_STREAM 0))
> (address (make-socket-address AF_UNIX file-name)))
> (false-if-exception (connect sock address))))) ; probably missing a
> "[catch] close". How to do that best?
That’s a pretty good test. Note that (gnu services herd) and (shepherd
comm) already provide an ‘open-connection’ procedure to do that.
>From a shell script, you can also simply run “herd status root” and
check the exit status.
> I'm trying to find the right place to insert my "dbus-daemon" invocation for
> providing the user bus (note: not session bus)...
What’s the difference between a “user bus” and a “session bus”? In
general, my understanding is that the user dbus-daemon (session bus?) is
started on demand.
> Should we make a system shepherd service that invokes the user shepherd
> service on behalf of users? Would that be that safe?
The “guix user” approach that Mathieu shown is more flexible than having
to do something in the ‘operating-system’ declaration IMO.
> Or should we just expect the user to put a (shepherd with fix) invocation
> into their HOME startup scripts like .xinitrc ? Note that if we did that
> there's some session-specific stuff in the session's environment that
> shepherd will inherit. Probably not that bad if invoked early enough.
Currently that’s what I do: my ~/.xinitrc runs shepherd and that’s it.
HTH,
Ludo’.