From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Sockets in Shepherd, and Emacs, oh my!
Date: Mon, 11 Apr 2022 06:23:05 +0200 [thread overview]
Message-ID: <156738d0efb4fa5ef2af08c5a8b485b4f1044f22.camel@gmail.com> (raw)
In-Reply-To: <87o8184qpd.fsf@gnu.org>
Hi,
Am Sonntag, dem 10.04.2022 um 22:40 +0200 schrieb Ludovic Courtès:
> 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)))
Addendum: This only worked, because I had the directory already
created. For the directory to be created with the correct permissions,
you need to add #:socket-directory-permissions #o700.
> 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.
Emacs without systemd support simply exits, because Shepherd owns the
socket. I think a rather simple command that exits immediately or
after sleep 5 ought to do the trick.
> > 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.
Sure, but in neither case appears the dying process to be handled
correctly. If shepherd doesn't check whether the service takes over,
it might even be the same bug, but I didn't check if the correctly
spawned emacs becomes a zombie. At the very least I'd argue it'd be
cleaned up during manual service restart, which is needed to get your
socket back.
>
Cheers
next prev parent reply other threads:[~2022-04-11 4:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 18:40 Sockets in Shepherd, and Emacs, oh my! Liliana Marie Prikler
2022-04-10 20:40 ` Ludovic Courtès
2022-04-11 4:23 ` Liliana Marie Prikler [this message]
2022-04-18 19:43 ` Ludovic Courtès
2022-04-18 21:14 ` Liliana Marie Prikler
2022-04-20 9:50 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=156738d0efb4fa5ef2af08c5a8b485b4f1044f22.camel@gmail.com \
--to=liliana.prikler@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).