Hi, Am Sonntag, dem 10.04.2022 um 22:40 +0200 schrieb Ludovic Courtès: > Hallo! > > Liliana Marie Prikler <liliana.prik...@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