guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sockets in Shepherd, and Emacs, oh my!


From: Ludovic Courtès
Subject: Re: Sockets in Shepherd, and Emacs, oh my!
Date: Sun, 10 Apr 2022 22:40:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hallo!

Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

> given that Shepherd 0.9.0 adds support for systemd-style socket
> activation and Emacs supports that (if linked against systemd!) I
> wanted to try it out.  Here's my "generic" recipe for constructing
> an Emacs service:
>
> (define* (emacs #:key (name 'server)
>                 (uid (getuid))
>                 (gid (getgid)))
>   (make <service>
>     #:provides (list
>                 (symbol-append 'emacs@ name))
>     #:requires '()
>     #:start
>     (make-systemd-constructor
>      (list "emacs" "--fg-daemon")
>      (list (endpoint
>             (make-socket-address AF_UNIX
>                                  (format #f "/run/user/~d/emacs/~s"
>                                          uid name))
>             #:socket-owner uid
>             #:socket-group gid)))
>     #:stop (make-systemd-destructor)))

Fun!  Good to see this put to good use.  :-)

> There appear to be some bugs, though.  If shepherd launches a process
> via systemd-constructor and it dies before claiming the socket, it
> will become a zombie.

What do you mean by “claiming the socket”?  Do you have a log file
showing this, or at (better yet) a small reproducer?  You can use
‘tests/systemd.sh’ as a starting point.

> Further, if the process dies after having claimed the socket, shepherd
> will not reset service's entry points and running value.  Both should
> be fixable in my opinion.

The running value is changed as soon as the child process is started by
‘make-systemd-constructor’, AFAICS.  But maybe I’m overlooking
something.

> So, what's for the future?  If someone wants to do so, they could
> adapt my shepherd service for Guix Home.  It'd be very nice to one
> day be able to spawn an Emacs service fine-tuned to desired editing
> purposes.  Think of using `guix shell --container' building packages
> that you'd otherwise rarely need on demand, for example.
>
> With that in mind, happy hacking!

Sounds fun!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]