From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.emacs.devel,gmane.comp.gnu.guix.devel 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 Message-ID: <87v84de8fb.fsf@gnu.org> References: <20240410234923.29319-2-ngraves@ngraves.fr> <875xwotg35.fsf@trop.in> <87zfu0m9ps.fsf@ngraves.fr> <87jzl22u5w.fsf@gnu.org> <87cyqtnr5h.fsf@ngraves.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8292"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: "Nicolas Graves via Development of GNU Guix and the GNU System distribution." , emacs-devel@gnu.org, Andrew Tropin , Stefan Monnier To: Nicolas Graves Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 19 16:26:14 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rxpBu-0001qM-L2 for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Apr 2024 16:26:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxpBN-0004YB-IQ; Fri, 19 Apr 2024 10:25:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxpBJ-0004VA-7m; Fri, 19 Apr 2024 10:25:37 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxpBG-00085O-0P; Fri, 19 Apr 2024 10:25:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=nsQdpXt7nBfVoveL2F/Ir6EsFuYaLQ/+xogmMBw7LCQ=; b=ZYRw6tp7nfEuRdqAzM0A ec1tMj3OYYs86dsipeyiYcLtkMHsdRZ4Io8Z7vJYREAGqbfLzJu85lhx2VL4Ybu+kT11LkCW0rQNZ tZlALQjYBErnXdaYUQXV66tQhzNmMPKFWV4slj9nFkHMGL0J9GLhNo+WzRZ9z9Pf90RRawxhEoKYM pEvi0YnKT5il1kRpYGXenCczdKrZZVa4T/7mRPdldyGJ6/i6K86eqn1JHDfa/ealrg/PjatlnzZYk 83ctW/plyaAG/T5XgJCPVZ/G9pR/VE8dJXZBaGf8RCjc/PTjkKsjidLFRDJfbv8jB0kZyxhPcvvH9 Fw7jNBfGhiFkEg==; In-Reply-To: <87cyqtnr5h.fsf@ngraves.fr> (Nicolas Graves's message of "Sat, 13 Apr 2024 18:50:18 +0200") X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Primidi 1 =?utf-8?Q?Flor=C3=A9al?= an 232 de la =?utf-8?Q?R=C3=A9volution=2C?= jour de la Rose X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317840 gmane.comp.gnu.guix.devel:69975 Archived-At: Hi, Nicolas Graves 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=3D~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=3D> (lookup-service 'emacs-server) service-status)" > thus giving a nice "Emacs is currently starting" notification. With socket activation, the service is immediately in =E2=80=9Crunning=E2= =80=9D state: starting it requires nothing more than accepting connections on the socket. (Maybe that=E2=80=99s 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=E2=80=99.