all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Nicolas Graves <ngraves@ngraves.fr>
Cc: "Nicolas Graves via Development of GNU Guix and the GNU System
	distribution." <guix-devel@gnu.org>,
	 emacs-devel@gnu.org,  Andrew Tropin <andrew@trop.in>,
	 Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file
Date: Fri, 19 Apr 2024 16:25:28 +0200	[thread overview]
Message-ID: <87v84de8fb.fsf@gnu.org> (raw)
In-Reply-To: <87cyqtnr5h.fsf@ngraves.fr> (Nicolas Graves's message of "Sat, 13 Apr 2024 18:50:18 +0200")

Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

> (define (emacs-shepherd-service config name)
>   (shepherd-service
>    (documentation
>     (format #f "Emacs server.  Use ~a to connect to it."
>             (if (eq? 'server name)
>                 "@code{emacsclient}"
>                 (format #f "@code{emacsclient -s ~a}" name))))
>    (provision `(,(symbol-append 'emacs- name)))
>    (requirement '(emacs))
>    (modules '((shepherd support)))  ;for '%user-runtime-dir'
>    (start #~(make-systemd-constructor
>              (list #$(file-append
>                       (home-emacs-configuration-emacs config)
>                       "/bin/emacs") #$(format #f "--fg-daemon=~a" name))
>              (list (endpoint
>                     (make-socket-address
>                      AF_UNIX
>                      (string-append %user-runtime-dir
>                                     "/emacs/" #$(symbol->string name)))
>                     #:name '#$(format #f "emacs-~a" name)
>                     #:socket-directory-permissions #o700))
>              #:log-file (string-append
>                          (getenv "XDG_STATE_HOME") "/log"
>                          "/emacs-" #$(symbol->string name) ".log")))
>    (stop #~(make-systemd-destructor))))

Note that in this case the server is started lazily, the first time
someone connects to the socket.

You can pass #:lazy-start? #false if you instead want to start it
upfront.

> But I'm not sure it's better regarding user experience. On RDE we
> implemented a notifier that parses the result of
> herd eval root "(and=> (lookup-service 'emacs-server) service-status)"
> thus giving a nice "Emacs is currently starting" notification.

With socket activation, the service is immediately in “running” state:
starting it requires nothing more than accepting connections on the
socket.

(Maybe that’s one of the rare situations where sd-notify would help?)

> This evaluation doesn't seem to work using make-systemd-constructor,
> although it has its advantages (indeed launches a frame when available).
> It would be nice if service-status could "sync" with
> make-systemd-constructor in this case.
>
> I would be happy to send such a patch for Guix (is there already some
> patch series on which to graft this?), WDYT @Ludo?

Sure, feel free to send a patch for this; there are unfortunately
several attempts at an Emacs service in the issue tracker, but none of
them made it to the tree so far, in part because some were very
ambitious.

Thanks,
Ludo’.



  reply	other threads:[~2024-04-19 14:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240410234923.29319-2-ngraves@ngraves.fr>
     [not found] ` <875xwotg35.fsf@trop.in>
2024-04-11 11:15   ` [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-04-12 20:38     ` Ludovic Courtès
2024-04-13 14:20       ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-04-13 15:09         ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-04-13 15:16         ` Stefan Monnier
2024-04-14 19:11           ` Björn Bidar
2024-04-14 19:11           ` Björn Bidar
     [not found]           ` <87le5f2202.fsf@>
2024-04-14 20:52             ` Stefan Monnier
2024-04-19 14:19               ` Ludovic Courtès
2024-04-19 14:36                 ` Rudolf Schlatte
2024-04-20  2:31                   ` Stefan Monnier
2024-04-19 14:17             ` Ludovic Courtès
2024-05-11 20:15           ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-11 23:07             ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-12  6:29               ` Eli Zaretskii
2024-05-12  7:50                 ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-12  7:54                   ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-12  9:36                   ` Eli Zaretskii
2024-05-12 11:11                     ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-12 15:01                       ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-04-13 16:50       ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-04-19 14:25         ` Ludovic Courtès [this message]
2024-04-14 16:51       ` Felix Lechner via Development of GNU Guix and the GNU System distribution.

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v84de8fb.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=andrew@trop.in \
    --cc=emacs-devel@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=ngraves@ngraves.fr \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.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.