GNU bug report logs - #16507
24.3; systemd unit for a GNU Emacs daemon

Previous Next

Package: emacs;

Reported by: Philipp Moeller <bootsarehax <at> gmail.com>

Date: Mon, 20 Jan 2014 16:48:03 UTC

Severity: wishlist

Found in version 24.3

Fixed in version 26.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16507 in the body.
You can then email your comments to 16507 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 16:48:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Philipp Moeller <bootsarehax <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 20 Jan 2014 16:48:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Philipp Moeller <bootsarehax <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 13:34:51 +0100
systemd provides an easy way to set-up a per-user Emacs daemon and there
are several unit files floating around the web. One that works is:

  /etc/systemd/system/emacs@.service
  ----------------------------------
  [Unit]
  Description=GNU Emacs: the extensible, self-documenting text editor
  
  [Service]
  Type=forking
  ExecStart=/usr/bin/emacs --daemon
  ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
  Restart=always
  User=%i
  
  [Install]
  WantedBy=multi-user.target

It would be helpful to include this with the default GNU Emacs, so
users don't need to maintain their own files.

The above file would need some configuration through configure to set
the install path correctly and there should be an option to enable or
disable installing it via --with-systemd.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 16:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Philipp Moeller <bootsarehax <at> gmail.com>
Cc: 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 17:58:01 +0100
Philipp Moeller <bootsarehax <at> gmail.com> writes:

>   ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"

'nil is the same as nil.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 17:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Philipp Moeller <bootsarehax <at> gmail.com>, 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 12:05:24 -0500
Andreas Schwab wrote:

>>   ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
>
> 'nil is the same as nil.

Also: why set kill-emacs-hook to nil at all?

If it is to avoid prompting: "functions placed on this hook should not
expect to be able to interact with the user.  To ask for confirmation,
see `kill-emacs-query-functions' instead."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 18:52:01 GMT) Full text and rfc822 format available.

Message #14 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: Philipp Moeller <bootsarehax <at> gmail.com>
Cc: 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 13:53:26 -0500
On Mon, 20 Jan 2014 13:34:51 +0100 Philipp Moeller <bootsarehax <at> gmail.com> wrote: 

PM> systemd provides an easy way to set-up a per-user Emacs daemon and there
PM> are several unit files floating around the web. One that works is:
...
PM> It would be helpful to include this with the default GNU Emacs, so
PM> users don't need to maintain their own files.

PM> The above file would need some configuration through configure to set
PM> the install path correctly and there should be an option to enable or
PM> disable installing it via --with-systemd.

I would like that as part of the package, even if 95% of users never
need it.  The 5% that do will appreciate the convenience.

Ted




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 20:26:02 GMT) Full text and rfc822 format available.

Message #17 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Philipp Moeller <bootsarehax <at> gmail.com>
Cc: 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 15:25:48 -0500
> I would like that as part of the package, even if 95% of users never
> need it.  The 5% that do will appreciate the convenience.

I don't see any problem with adding such a file.
I guess it would go in `etc'?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 21:04:01 GMT) Full text and rfc822 format available.

Message #20 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Philipp Moeller <bootsarehax <at> gmail.com>, 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 16:03:04 -0500
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> I don't see any problem with adding such a file.  I guess it would go
> in `etc'?

I think the suggestion was that it could be a build feature like
--with-systemd-unit-file or something like that.  That would indeed be
nice.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 20 Jan 2014 22:37:02 GMT) Full text and rfc822 format available.

Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Mon, 20 Jan 2014 17:36:13 -0500
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> I would like that as part of the package, even if 95% of users never
>> need it.  The 5% that do will appreciate the convenience.
>
> I don't see any problem with adding such a file.
> I guess it would go in `etc'?
>
>
>         Stefan

Units of installed packages go in lib, per systemd.unit(5)

The addition of a user unit should also be considered.  Here is an example:

[Unit]
Description=GNU Emacs daemon
Documentation=man:emacs(1) info:Emacs

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"

[Install]
WantedBy=default.target




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Wed, 03 Dec 2014 19:41:02 GMT) Full text and rfc822 format available.

Message #26 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
To: emacs-devel <at> gnu.org
Cc: 16507 <at> debbugs.gnu.org
Subject: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Wed, 03 Dec 2014 20:39:44 +0100
As discussed in Bug#16507, I've added a systemd service file to deal with 
emacs --daemon.  This however requires some installation changes.  That's why 
I submit this patch for review before pushing it.

A new configuration flag `--with-systemduserunitdir' is added to set the 
installation directory for the user unit.  If it is unset an attempt is made 
to locate the default directory by using pkg-config.

(I guess this should also get an entry in etc/NEWS.)

* configure.ac (with_systemduserunitdir): New option.
* Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables.
(install-etc): Install systemd unit file.
(uninstall): Uninstall systemd unit file.
* etc/emacs.service.in: New file.
---
 ChangeLog            |  8 ++++++++
 Makefile.in          | 17 +++++++++++++++++
 configure.ac         | 19 +++++++++++++++++++
 etc/ChangeLog        |  5 +++++
 etc/emacs.service.in | 14 ++++++++++++++
 5 files changed, 63 insertions(+)
 create mode 100644 etc/emacs.service.in

diff --git a/ChangeLog b/ChangeLog
index cd7698c..05ad878 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-12-03  Rüdiger Sonderfeld  <ruediger <at> c-plusplus.de>
+
+	Add a systemd service file for dealing with emacs --daemon.
+	* configure.ac (with_systemduserunitdir): New option.
+	* Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables.
+	(install-etc): Install systemd unit file.
+	(uninstall): Uninstall systemd unit file.
+
 2014-12-01  Lars Magne Ingebrigtsen  <larsi <at> gnus.org>
 
 	* .gitignore: Ignore loaddefs directly under lisp, and in
diff --git a/Makefile.in b/Makefile.in
index ccb70a4..b1e6be5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -241,6 +241,9 @@ etcdocdir=@etcdocdir@
 # Where to install Emacs game score files.
 gamedir=@gamedir@
 
+# Where to install systemd unit files.
+systemdunitdir=@systemdunitdir@
+
 # ==================== Utility Programs for the Build ====================
 
 # Allow the user to specify the install program.
@@ -286,6 +289,9 @@ SUBDIR_MAKEFILES = `echo $(SUBDIR_MAKEFILES_IN:.in=) | sed 
's|$(srcdir)/||g'`
 COPYDIR = ${srcdir}/etc ${srcdir}/lisp
 COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
 
+# systemd unit
+SYSTEMD_UNITS = @SYSTEMD_UNITS@
+
 all: ${SUBDIR} info
 
 .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver
@@ -716,6 +722,16 @@ install-etc:
 	    || exit 1; \
 	  done ; \
 	done
+	if test "x$(SYSTEMD_UNITS)" = "xemacs.service" ; then \
+	  tmp=etc/emacs.service; rm -f $${tmp}; \
+	  sed \
+            -e "s;@emacs_prog@;${bindir}/${EMACSFULL};" \
+	    -e "s;@emacsclient_prog@;${bindir}/emacsclient${EXEEXT};" \
+	    "$(srcdir)/etc/emacs.service.in" > $${tmp}; \
+	  umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"; \
+	  $(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/emacs.service"; \
+	  rm -f $${tmp}; \
+	fi
 
 ### Build Emacs and install it, stripping binaries while installing them.
 install-strip:
@@ -771,6 +787,7 @@ uninstall: uninstall-$(NTDIR) uninstall-doc
 	  file="$(DESTDIR)${gamedir}/$${file}"; \
 	  [ -s "$${file}" ] || rm -f "$$file"; \
 	done
+	-rm -f "$(DESTDIR)$(systemdunitdir)/emacs.service"
 
 ### Windows-specific uninstall target for removing programs produced
 ### in nt/, and its Posix do-nothing shadow.
diff --git a/configure.ac b/configure.ac
index 010abc8..e737f1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -374,6 +374,10 @@ otherwise for the first of `gfile' or `inotify' that is 
usable.])
  ],
  [with_file_notification=$with_features])
 
+AC_ARG_WITH([systemduserunitdir],
+ AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user 
service files]),
+ [], [with_systemduserunitdir=default])
+
 ## For the times when you want to build Emacs but don't have
 ## a suitable makeinfo, and can live without the manuals.
 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
@@ -2678,6 +2682,21 @@ AC_SUBST(NOTIFY_OBJ)
 AC_SUBST(GFILENOTIFY_CFLAGS)
 AC_SUBST(GFILENOTIFY_LIBS)
 
+if test "x$with_systemduserunitdir" != xno; then
+  if test "x$with_systemduserunitdir" = xdefault; then
+    with_systemduserunitdir=`"$PKG_CONFIG" --variable=systemduserunitdir 
systemd`
+  fi
+  AC_SUBST([systemdunitdir], [$with_systemduserunitdir])
+fi
+
+if test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno ; 
then
+  SYSTEMD_UNITS="emacs.service"
+else
+  SYSTEMD_UNITS=""
+fi
+
+AC_SUBST(SYSTEMD_UNITS)
+
 dnl Do not put whitespace before the #include statements below.
 dnl Older compilers (eg sunos4 cc) choke on it.
 HAVE_XAW3D=no
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 4f672df..02c0895 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-03  Rüdiger Sonderfeld  <ruediger <at> c-plusplus.de>
+
+	Add a systemd service file for dealing with emacs --daemon.
+	* emacs.service.in: New file.
+
 2014-12-02  Eli Zaretskii  <eliz <at> gnu.org>
 
 	* NEWS: Mention 'bidi-find-overridden-directionality'.
diff --git a/etc/emacs.service.in b/etc/emacs.service.in
new file mode 100644
index 0000000..0e59bc2
--- /dev/null
+++ b/etc/emacs.service.in
@@ -0,0 +1,14 @@
+# -*- conf-mode -*-
+# Copyright (C) 2014 Free Software Foundation, Inc.
+[Unit]
+Description=Emacs: the extensible, customizable text editor - and more.
+Documentation=info:Emacs man:emacs(1) https://gnu.org/software/emacs/
+
+[Service]
+Type=forking
+ExecStart=@emacs_prog@ --daemon
+ExecStop=@emacsclient_prog@ --eval "(kill-emacs)"
+Restart=on-failure
+
+[Install]
+WantedBy=default.target
-- 
2.1.3





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Wed, 03 Dec 2014 21:09:01 GMT) Full text and rfc822 format available.

Message #29 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Romain Francoise <romain <at> orebokech.com>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Cc: 16507 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Wed, 03 Dec 2014 22:08:37 +0100
Hi,

On Wed, Dec 03, 2014 at 08:39:44PM +0100, Rüdiger Sonderfeld wrote:
> As discussed in Bug#16507, I've added a systemd service file to deal
> with emacs --daemon. This however requires some installation changes.
> That's why I submit this patch for review before pushing it.

Is this something that distributions would be expected to enable?
Because I use both systemd and Emacs, yet I absolutely don't want to
have an Emacs daemon started by default in my user instance.

Also, by default user instances are killed when the last session is
closed, which would therefore kill the emacs process and kinda defeat
the point of having a persistent daemon.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Wed, 03 Dec 2014 21:18:02 GMT) Full text and rfc822 format available.

Message #32 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: joakim <at> verona.se
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Cc: 16507 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Wed, 03 Dec 2014 22:16:45 +0100
Rüdiger Sonderfeld <ruediger <at> c-plusplus.net> writes:

> As discussed in Bug#16507, I've added a systemd service file to deal with 
> emacs --daemon.  This however requires some installation changes.  That's why 
> I submit this patch for review before pushing it.
>
> A new configuration flag `--with-systemduserunitdir' is added to set the 
> installation directory for the user unit.  If it is unset an attempt is made 
> to locate the default directory by using pkg-config.
>
> (I guess this should also get an entry in etc/NEWS.)
>
> * configure.ac (with_systemduserunitdir): New option.
> * Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables.
> (install-etc): Install systemd unit file.
> (uninstall): Uninstall systemd unit file.
> * etc/emacs.service.in: New file.
> ---
>  ChangeLog            |  8 ++++++++
>  Makefile.in          | 17 +++++++++++++++++
>  configure.ac         | 19 +++++++++++++++++++
>  etc/ChangeLog        |  5 +++++
>  etc/emacs.service.in | 14 ++++++++++++++
>  5 files changed, 63 insertions(+)
>  create mode 100644 etc/emacs.service.in
>
> diff --git a/ChangeLog b/ChangeLog
> index cd7698c..05ad878 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,11 @@
> +2014-12-03  Rüdiger Sonderfeld  <ruediger <at> c-plusplus.de>
> +
> +	Add a systemd service file for dealing with emacs --daemon.
> +	* configure.ac (with_systemduserunitdir): New option.
> +	* Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables.
> +	(install-etc): Install systemd unit file.
> +	(uninstall): Uninstall systemd unit file.
> +
>  2014-12-01  Lars Magne Ingebrigtsen  <larsi <at> gnus.org>
>  
>  	* .gitignore: Ignore loaddefs directly under lisp, and in
> diff --git a/Makefile.in b/Makefile.in
> index ccb70a4..b1e6be5 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -241,6 +241,9 @@ etcdocdir=@etcdocdir@
>  # Where to install Emacs game score files.
>  gamedir=@gamedir@
>  
> +# Where to install systemd unit files.
> +systemdunitdir=@systemdunitdir@
> +
>  # ==================== Utility Programs for the Build ====================
>  
>  # Allow the user to specify the install program.
> @@ -286,6 +289,9 @@ SUBDIR_MAKEFILES = `echo $(SUBDIR_MAKEFILES_IN:.in=) | sed 
> 's|$(srcdir)/||g'`
>  COPYDIR = ${srcdir}/etc ${srcdir}/lisp
>  COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
>  
> +# systemd unit
> +SYSTEMD_UNITS = @SYSTEMD_UNITS@
> +
>  all: ${SUBDIR} info
>  
>  .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver
> @@ -716,6 +722,16 @@ install-etc:
>  	    || exit 1; \
>  	  done ; \
>  	done
> +	if test "x$(SYSTEMD_UNITS)" = "xemacs.service" ; then \
> +	  tmp=etc/emacs.service; rm -f $${tmp}; \
> +	  sed \
> +            -e "s;@emacs_prog@;${bindir}/${EMACSFULL};" \
> +	    -e "s;@emacsclient_prog@;${bindir}/emacsclient${EXEEXT};" \
> +	    "$(srcdir)/etc/emacs.service.in" > $${tmp}; \
> +	  umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"; \
> +	  $(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/emacs.service"; \
> +	  rm -f $${tmp}; \
> +	fi
>  
>  ### Build Emacs and install it, stripping binaries while installing them.
>  install-strip:
> @@ -771,6 +787,7 @@ uninstall: uninstall-$(NTDIR) uninstall-doc
>  	  file="$(DESTDIR)${gamedir}/$${file}"; \
>  	  [ -s "$${file}" ] || rm -f "$$file"; \
>  	done
> +	-rm -f "$(DESTDIR)$(systemdunitdir)/emacs.service"
>  
>  ### Windows-specific uninstall target for removing programs produced
>  ### in nt/, and its Posix do-nothing shadow.
> diff --git a/configure.ac b/configure.ac
> index 010abc8..e737f1b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -374,6 +374,10 @@ otherwise for the first of `gfile' or `inotify' that is 
> usable.])
>   ],
>   [with_file_notification=$with_features])
>  
> +AC_ARG_WITH([systemduserunitdir],
> + AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user 
> service files]),
> + [], [with_systemduserunitdir=default])
> +
>  ## For the times when you want to build Emacs but don't have
>  ## a suitable makeinfo, and can live without the manuals.
>  dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html@@ -2678,6 +2682,21 @@ AC_SUBST(NOTIFY_OBJ)
>  AC_SUBST(GFILENOTIFY_CFLAGS)
>  AC_SUBST(GFILENOTIFY_LIBS)
>  
> +if test "x$with_systemduserunitdir" != xno; then
> +  if test "x$with_systemduserunitdir" = xdefault; then
> +    with_systemduserunitdir=`"$PKG_CONFIG" --variable=systemduserunitdir 
> systemd`
> +  fi
> +  AC_SUBST([systemdunitdir], [$with_systemduserunitdir])
> +fi
> +
> +if test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno ; 
> then
> +  SYSTEMD_UNITS="emacs.service"
> +else
> +  SYSTEMD_UNITS=""
> +fi
> +
> +AC_SUBST(SYSTEMD_UNITS)
> +
>  dnl Do not put whitespace before the #include statements below.
>  dnl Older compilers (eg sunos4 cc) choke on it.
>  HAVE_XAW3D=no
> diff --git a/etc/ChangeLog b/etc/ChangeLog
> index 4f672df..02c0895 100644
> --- a/etc/ChangeLog
> +++ b/etc/ChangeLog
> @@ -1,3 +1,8 @@
> +2014-12-03  Rüdiger Sonderfeld  <ruediger <at> c-plusplus.de>
> +
> +	Add a systemd service file for dealing with emacs --daemon.
> +	* emacs.service.in: New file.
> +
>  2014-12-02  Eli Zaretskii  <eliz <at> gnu.org>
>  
>  	* NEWS: Mention 'bidi-find-overridden-directionality'.
> diff --git a/etc/emacs.service.in b/etc/emacs.service.in
> new file mode 100644
> index 0000000..0e59bc2
> --- /dev/null
> +++ b/etc/emacs.service.in
> @@ -0,0 +1,14 @@
> +# -*- conf-mode -*-
> +# Copyright (C) 2014 Free Software Foundation, Inc.
> +[Unit]
> +Description=Emacs: the extensible, customizable text editor - and more.
> +Documentation=info:Emacs man:emacs(1) https://gnu.org/software/emacs/+
> +[Service]
> +Type=forking
> +ExecStart=@emacs_prog@ --daemon
> +ExecStop=@emacsclient_prog@ --eval "(kill-emacs)"
> +Restart=on-failure
> +
> +[Install]
> +WantedBy=default.target

I have a unit file that enables ssh-agent, which is otherwise a problem.
I'm not sure if its generally usable.


[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/ssh-agent /usr/local/bin/emacs --daemon
ExecStop=/usr/local/bin/emacs --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%i
WorkingDirectory=%h

[Install]
WantedBy=multi-user.target


The corresponding elisp looks like (warning, lame hard-coding):

(defun ssh-agent-init ()
  (interactive)
  (save-excursion
    (if (get-buffer "ssh-agent-process") (kill-buffer "ssh-agent-process" ))

    (with-current-buffer     (get-buffer-create "ssh-agent-process")
      (call-process "ssh-agent" nil t t  "-c" "-a" "/home/joakim/.ssh-agent-sock")

      (goto-char (point-min))

      (message "buf: %s cont: %s"(current-buffer) (buffer-string))

      (search-forward-regexp ".* .* \\(.*\\);")
      (message "1: %s" (match-string 0)(match-string 1))
      (setenv "SSH_AUTH_SOCK" (match-string 1))
      (setq ssh-auth-sock (getenv "SSH_AUTH_SOCK" ))
      (message "%s" (getenv "SSH_AUTH_SOCK" )))
    )
  )


(setenv "SSH_AUTH_SOCK" "/home/joakim/.ssh-agent-sock")

;;from the internetz
;; - it hangs, but works anyway
;; - it should also run ssh-agent-init intelligently

(defun ssh-add-process-filter (process string)
  (save-match-data
    (if (string-match ":\\s *\\'" string)
        (process-send-string process (concat (read-passwd string) "\n"))
      (message "%s" string))))
(defun ssh-add ()
  "Run ssh-add to add a key to the running SSH agent.
Let Emacs prompt for the passphrase."
(interactive)
  (let ((process-connection-type t)
            process)
    (unwind-protect
        (progn
          (setq process (start-process "ssh-add" nil
                                       "ssh-add" ))
          (set-process-filter process 'ssh-add-process-filter)
          (while (accept-process-output process)))
      (if (eq (process-status process) 'run)
          (kill-process process)))))


-- 
Joakim Verona




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Wed, 03 Dec 2014 21:45:02 GMT) Full text and rfc822 format available.

Message #35 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
To: emacs-devel <at> gnu.org
Cc: 16507 <at> debbugs.gnu.org, Romain Francoise <romain <at> orebokech.com>,
 Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Wed, 03 Dec 2014 22:44:03 +0100
On Wednesday 03 December 2014 22:08:37 Romain Francoise wrote:
> Is this something that distributions would be expected to enable?
> Because I use both systemd and Emacs, yet I absolutely don't want to
> have an Emacs daemon started by default in my user instance.

It's something the user would be expected to enable.  This should only provide 
the service file and the user can then enable it, using

    systemctl enable --user emacs.service

(or disable it by using disable).

> Also, by default user instances are killed when the last session is
> closed, which would therefore kill the emacs process and kinda defeat
> the point of having a persistent daemon.

Users should be able to prevent this, by using `loginctl enable-linger'.

Regards,
Rüdiger





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Wed, 03 Dec 2014 22:09:02 GMT) Full text and rfc822 format available.

Message #38 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Ulrich Mueller <ulm <at> gentoo.org>
To: Romain Francoise <romain <at> orebokech.com>
Cc: 16507 <at> debbugs.gnu.org, emacs-devel <at> gnu.org,
 Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Wed, 3 Dec 2014 23:08:29 +0100
>>>>> On Wed, 03 Dec 2014, Romain Francoise wrote:

> Is this something that distributions would be expected to enable?

As it is proposed, it won't work for Gentoo. We support installation
of several Emacs versions in parallel, so a systemd unit file
installed under a fixed path name would lead to file collisions
between different versions.

Which means that we shall disable installation of the file in Gentoo.
(Besides, systemd isn't our default init system ...)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Thu, 04 Dec 2014 00:19:02 GMT) Full text and rfc822 format available.

Message #41 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
To: emacs-devel <at> gnu.org
Cc: Ulrich Mueller <ulm <at> gentoo.org>, Romain Francoise <romain <at> orebokech.com>,
 16507 <at> debbugs.gnu.org
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Thu, 04 Dec 2014 01:18:11 +0100
On Wednesday 03 December 2014 23:08:29 Ulrich Mueller wrote:
> >>>>> On Wed, 03 Dec 2014, Romain Francoise wrote:
> > Is this something that distributions would be expected to enable?
> 
> As it is proposed, it won't work for Gentoo. We support installation
> of several Emacs versions in parallel, so a systemd unit file
> installed under a fixed path name would lead to file collisions
> between different versions.
> 
> Which means that we shall disable installation of the file in Gentoo.
> (Besides, systemd isn't our default init system ...)

Multiple versions are indeed an issue.  I don't know if the systemd folks have 
a suggestion for that case.  But as far as I understand the recommendation is 
indeed to install unit files to the directory given by pkg-config.

The installation directory can of course be changed and you could simply point 
it elsewhere and then have the user copy the unit file she wants.

Regards,
Rüdiger





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Thu, 04 Dec 2014 02:58:01 GMT) Full text and rfc822 format available.

Message #44 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>,
 emacs-devel <at> gnu.org
Cc: Ulrich Mueller <ulm <at> gentoo.org>, Romain Francoise <romain <at> orebokech.com>,
 16507 <at> debbugs.gnu.org
Subject: RE: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs --daemon.
Date: Wed, 3 Dec 2014 18:57:32 -0800 (PST)
Please drop one or the other from the recipients list:
emacs-devel or debbugs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Thu, 04 Dec 2014 03:01:02 GMT) Full text and rfc822 format available.

Message #47 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Cc: 16507 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs --daemon.
Date: Wed, 03 Dec 2014 22:00:44 -0500
Thanks, looks nice.
(Don't see why it needed to be posted to two mailing lists though.)

Should the name of the service file not respect program-transform though?
Ie, if I am installing the Emacs binary as "emacs24", should the service
file not be installed as "emacs24.service"?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Thu, 04 Dec 2014 06:28:01 GMT) Full text and rfc822 format available.

Message #50 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Ulrich Mueller <ulm <at> gentoo.org>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
Cc: 16507 <at> debbugs.gnu.org, Romain Francoise <romain <at> orebokech.com>,
 emacs-devel <at> gnu.org
Subject: Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
Date: Thu, 4 Dec 2014 07:26:53 +0100
>>>>> On Thu, 04 Dec 2014, Rüdiger Sonderfeld wrote:

> On Wednesday 03 December 2014 23:08:29 Ulrich Mueller wrote:
>> Which means that we shall disable installation of the file in
>> Gentoo. (Besides, systemd isn't our default init system ...)

> Multiple versions are indeed an issue. I don't know if the systemd
> folks have a suggestion for that case. But as far as I understand
> the recommendation is indeed to install unit files to the directory
> given by pkg-config.

> The installation directory can of course be changed and you could
> simply point it elsewhere and then have the user copy the unit file
> she wants.

IIUC, a copy of the file is installed with the data-directory (etc/)
anyway? So the file will be available to the user, even if not
installed in the pkgconfig location.

Alternatively, if there is users' demand for it, we (Gentoo) could
add the unit to another package (like app-emacs/emacs-common-gentoo
which contains the desktop files, or app-emacs/emacs-daemon). We try
to keep the number of files installed such at a minimum, though, and
follow upstream's install locations whereever possible.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Fri, 05 Dec 2014 17:28:01 GMT) Full text and rfc822 format available.

Message #53 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
To: bug-gnu-emacs <at> gnu.org, 16507 <at> debbugs.gnu.org
Cc: Glenn Morris <rgm <at> gnu.org>
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs --daemon.
Date: Fri, 05 Dec 2014 18:26:58 +0100
On Wednesday 03 December 2014 22:00:44 Glenn Morris wrote:
> Thanks, looks nice.
> (Don't see why it needed to be posted to two mailing lists though.)

Sorry about that.

> Should the name of the service file not respect program-transform though?
> Ie, if I am installing the Emacs binary as "emacs24", should the service
> file not be installed as "emacs24.service"?

That makes sense and would solve the problem of having several Emacs versions 
installed.

I'm a bit afraid that using the directory given by systemd might be confusing 
because it won't respect the prefix set by the user.  E.g., Emacs being 
installed to /usr/local but the service file going to /usr/lib/systemd/user.  
However, I think this is just the way systemd expects things to be and it 
would be up to the systemd developers to change this.

Regards,
Rüdiger





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Fri, 05 Dec 2014 17:28:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 08 Dec 2014 17:04:01 GMT) Full text and rfc822 format available.

Message #59 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
Cc: 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs --daemon.
Date: Mon, 08 Dec 2014 12:03:23 -0500
Rüdiger Sonderfeld wrote:

> I'm a bit afraid that using the directory given by systemd might be
> confusing because it won't respect the prefix set by the user. E.g.,
> Emacs being installed to /usr/local but the service file going to
> /usr/lib/systemd/user.

I agree that that is an issue. Personally I think you should respect
the user's prefix. For example, I often install software as a non-root
user into my local software space, and it's always annoying when
things try to install files into /usr (which fails due to lack of
permission).

It's going to take a bit of know-how to actually enable the service,
and I think people doing that will be able to cope with copying
the file to the appropriate location if they need to.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 08 Dec 2014 18:52:02 GMT) Full text and rfc822 format available.

Message #62 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>,
 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs --daemon.
Date: Mon, 08 Dec 2014 13:51:21 -0500
>> Emacs being installed to /usr/local but the service file going to
>> /usr/lib/systemd/user.
> I agree that that is an issue. Personally I think you should respect
> the user's prefix.

Indeed, if the prefix is /usr/local we should not install anything
outside /usr/local.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Mon, 08 Dec 2014 20:42:02 GMT) Full text and rfc822 format available.

Message #65 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: ruediger <at> c-plusplus.de, rgm <at> gnu.org, 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs	--daemon.
Date: Mon, 08 Dec 2014 22:41:20 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Mon, 08 Dec 2014 13:51:21 -0500
> Cc: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>,
> 	16507 <at> debbugs.gnu.org
> 
> >> Emacs being installed to /usr/local but the service file going to
> >> /usr/lib/systemd/user.
> > I agree that that is an issue. Personally I think you should respect
> > the user's prefix.
> 
> Indeed, if the prefix is /usr/local we should not install anything
> outside /usr/local.

AFAIK, there are packages out there which install stuff in /etc, so
I'm not sure this rule is valid.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16507; Package emacs. (Tue, 09 Dec 2014 02:48:01 GMT) Full text and rfc822 format available.

Message #68 received at 16507 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ruediger <at> c-plusplus.de, rgm <at> gnu.org, 16507 <at> debbugs.gnu.org
Subject: Re: bug#16507: [RFC] Add a systemd service file for dealing with
 emacs	--daemon.
Date: Mon, 08 Dec 2014 21:47:25 -0500
>> >> Emacs being installed to /usr/local but the service file going to
>> >> /usr/lib/systemd/user.
>> > I agree that that is an issue. Personally I think you should respect
>> > the user's prefix.
>> Indeed, if the prefix is /usr/local we should not install anything
>> outside /usr/local.
> AFAIK, there are packages out there which install stuff in /etc, so
> I'm not sure this rule is valid.

I'm talking about a general rule, which I think Emacs should follow.
Some other packages may have good reasons to break this rule, but
I can't think of any reason why Emacs should.


        Stefan




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Sun, 13 Nov 2016 23:53:01 GMT) Full text and rfc822 format available.

Notification sent to Philipp Moeller <bootsarehax <at> gmail.com>:
bug acknowledged by developer. (Sun, 13 Nov 2016 23:53:02 GMT) Full text and rfc822 format available.

Message #73 received at 16507-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 16507-done <at> debbugs.gnu.org
Subject: Re: bug#16507: 24.3; systemd unit for a GNU Emacs daemon
Date: Sun, 13 Nov 2016 18:52:03 -0500
Version: 26.1

An emacs.service file is now included (since 181bd84).
Sorry for the delay.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 12 Dec 2016 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 244 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.