* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
@ 2014-12-03 21:08 ` Romain Francoise
2014-12-03 21:44 ` Rüdiger Sonderfeld
` (3 more replies)
2014-12-03 21:08 ` Romain Francoise
` (4 subsequent siblings)
5 siblings, 4 replies; 31+ messages in thread
From: Romain Francoise @ 2014-12-03 21:08 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 21:08 ` Romain Francoise
@ 2014-12-03 21:44 ` Rüdiger Sonderfeld
2014-12-03 21:44 ` bug#16507: " Rüdiger Sonderfeld
` (2 subsequent siblings)
3 siblings, 0 replies; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-03 21:44 UTC (permalink / raw)
To: emacs-devel; +Cc: 16507, Romain Francoise, Rüdiger Sonderfeld
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 21:08 ` Romain Francoise
2014-12-03 21:44 ` Rüdiger Sonderfeld
@ 2014-12-03 21:44 ` Rüdiger Sonderfeld
2014-12-03 22:08 ` Ulrich Mueller
2014-12-03 22:08 ` bug#16507: " Ulrich Mueller
3 siblings, 0 replies; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-03 21:44 UTC (permalink / raw)
To: emacs-devel; +Cc: 16507, Romain Francoise, Rüdiger Sonderfeld
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 21:08 ` Romain Francoise
2014-12-03 21:44 ` Rüdiger Sonderfeld
2014-12-03 21:44 ` bug#16507: " Rüdiger Sonderfeld
@ 2014-12-03 22:08 ` Ulrich Mueller
2014-12-04 0:18 ` bug#16507: " Rüdiger Sonderfeld
2014-12-04 0:18 ` Rüdiger Sonderfeld
2014-12-03 22:08 ` bug#16507: " Ulrich Mueller
3 siblings, 2 replies; 31+ messages in thread
From: Ulrich Mueller @ 2014-12-03 22:08 UTC (permalink / raw)
To: Romain Francoise; +Cc: 16507, emacs-devel, Rüdiger Sonderfeld
>>>>> 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 ...)
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 22:08 ` Ulrich Mueller
@ 2014-12-04 0:18 ` Rüdiger Sonderfeld
2014-12-04 0:18 ` Rüdiger Sonderfeld
1 sibling, 0 replies; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-04 0:18 UTC (permalink / raw)
To: emacs-devel; +Cc: Ulrich Mueller, Romain Francoise, 16507
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 22:08 ` Ulrich Mueller
2014-12-04 0:18 ` bug#16507: " Rüdiger Sonderfeld
@ 2014-12-04 0:18 ` Rüdiger Sonderfeld
2014-12-04 2:57 ` bug#16507: " Drew Adams
` (3 more replies)
1 sibling, 4 replies; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-04 0:18 UTC (permalink / raw)
To: emacs-devel; +Cc: Ulrich Mueller, Romain Francoise, 16507
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 0:18 ` Rüdiger Sonderfeld
@ 2014-12-04 2:57 ` Drew Adams
2014-12-04 2:57 ` Drew Adams
` (2 subsequent siblings)
3 siblings, 0 replies; 31+ messages in thread
From: Drew Adams @ 2014-12-04 2:57 UTC (permalink / raw)
To: Rüdiger Sonderfeld, emacs-devel
Cc: Ulrich Mueller, Romain Francoise, 16507
Please drop one or the other from the recipients list:
emacs-devel or debbugs.
^ permalink raw reply [flat|nested] 31+ messages in thread
* RE: bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 0:18 ` Rüdiger Sonderfeld
2014-12-04 2:57 ` bug#16507: " Drew Adams
@ 2014-12-04 2:57 ` Drew Adams
2014-12-04 6:26 ` Ulrich Mueller
2014-12-04 6:26 ` Ulrich Mueller
3 siblings, 0 replies; 31+ messages in thread
From: Drew Adams @ 2014-12-04 2:57 UTC (permalink / raw)
To: Rüdiger Sonderfeld, emacs-devel
Cc: Ulrich Mueller, Romain Francoise, 16507
Please drop one or the other from the recipients list:
emacs-devel or debbugs.
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 0:18 ` Rüdiger Sonderfeld
2014-12-04 2:57 ` bug#16507: " Drew Adams
2014-12-04 2:57 ` Drew Adams
@ 2014-12-04 6:26 ` Ulrich Mueller
2014-12-04 6:26 ` Ulrich Mueller
3 siblings, 0 replies; 31+ messages in thread
From: Ulrich Mueller @ 2014-12-04 6:26 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, Romain Francoise, emacs-devel
>>>>> 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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 0:18 ` Rüdiger Sonderfeld
` (2 preceding siblings ...)
2014-12-04 6:26 ` Ulrich Mueller
@ 2014-12-04 6:26 ` Ulrich Mueller
2014-12-04 14:04 ` Rüdiger Sonderfeld
3 siblings, 1 reply; 31+ messages in thread
From: Ulrich Mueller @ 2014-12-04 6:26 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, Romain Francoise, emacs-devel
>>>>> 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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 6:26 ` Ulrich Mueller
@ 2014-12-04 14:04 ` Rüdiger Sonderfeld
0 siblings, 0 replies; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-04 14:04 UTC (permalink / raw)
To: emacs-devel, Romain Francoise; +Cc: Ulrich Mueller
On Thursday 04 December 2014 07:26:53 Ulrich Mueller wrote:
> 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.
No, the data directory etc/ should not be automatically be installed anywhere.
The emacs.service file is only generated and installed, if either pkgconfig
provides the default location or the user explicitly sets it.
> 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.
That probably makes sense.
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 21:08 ` Romain Francoise
` (2 preceding siblings ...)
2014-12-03 22:08 ` Ulrich Mueller
@ 2014-12-03 22:08 ` Ulrich Mueller
3 siblings, 0 replies; 31+ messages in thread
From: Ulrich Mueller @ 2014-12-03 22:08 UTC (permalink / raw)
To: Romain Francoise; +Cc: 16507, Rüdiger Sonderfeld, emacs-devel
>>>>> 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 ...)
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
2014-12-03 21:08 ` Romain Francoise
@ 2014-12-03 21:08 ` Romain Francoise
2014-12-03 21:16 ` joakim
` (3 subsequent siblings)
5 siblings, 0 replies; 31+ messages in thread
From: Romain Francoise @ 2014-12-03 21:08 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
2014-12-03 21:08 ` Romain Francoise
2014-12-03 21:08 ` Romain Francoise
@ 2014-12-03 21:16 ` joakim
2014-12-03 21:16 ` bug#16507: " joakim
` (2 subsequent siblings)
5 siblings, 0 replies; 31+ messages in thread
From: joakim @ 2014-12-03 21:16 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
Rüdiger Sonderfeld <ruediger@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@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@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@c-plusplus.de>
> +
> + Add a systemd service file for dealing with emacs --daemon.
> + * emacs.service.in: New file.
> +
> 2014-12-02 Eli Zaretskii <eliz@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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
` (2 preceding siblings ...)
2014-12-03 21:16 ` joakim
@ 2014-12-03 21:16 ` joakim
2014-12-04 3:00 ` Glenn Morris
2014-12-04 3:00 ` Glenn Morris
5 siblings, 0 replies; 31+ messages in thread
From: joakim @ 2014-12-03 21:16 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
Rüdiger Sonderfeld <ruediger@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@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@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@c-plusplus.de>
> +
> + Add a systemd service file for dealing with emacs --daemon.
> + * emacs.service.in: New file.
> +
> 2014-12-02 Eli Zaretskii <eliz@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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
` (3 preceding siblings ...)
2014-12-03 21:16 ` bug#16507: " joakim
@ 2014-12-04 3:00 ` Glenn Morris
2014-12-04 3:00 ` Glenn Morris
5 siblings, 0 replies; 31+ messages in thread
From: Glenn Morris @ 2014-12-04 3:00 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
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"?
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-03 19:39 ` bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon Rüdiger Sonderfeld
` (4 preceding siblings ...)
2014-12-04 3:00 ` Glenn Morris
@ 2014-12-04 3:00 ` Glenn Morris
2014-12-05 17:26 ` Rüdiger Sonderfeld
5 siblings, 1 reply; 31+ messages in thread
From: Glenn Morris @ 2014-12-04 3:00 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507, emacs-devel
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"?
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-04 3:00 ` Glenn Morris
@ 2014-12-05 17:26 ` Rüdiger Sonderfeld
2014-12-08 17:03 ` Glenn Morris
0 siblings, 1 reply; 31+ messages in thread
From: Rüdiger Sonderfeld @ 2014-12-05 17:26 UTC (permalink / raw)
To: 16507
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-05 17:26 ` Rüdiger Sonderfeld
@ 2014-12-08 17:03 ` Glenn Morris
2014-12-08 18:51 ` Stefan Monnier
0 siblings, 1 reply; 31+ messages in thread
From: Glenn Morris @ 2014-12-08 17:03 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: 16507
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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-08 17:03 ` Glenn Morris
@ 2014-12-08 18:51 ` Stefan Monnier
2014-12-08 20:41 ` Eli Zaretskii
0 siblings, 1 reply; 31+ messages in thread
From: Stefan Monnier @ 2014-12-08 18:51 UTC (permalink / raw)
To: Glenn Morris; +Cc: Rüdiger Sonderfeld, 16507
>> 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
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-08 18:51 ` Stefan Monnier
@ 2014-12-08 20:41 ` Eli Zaretskii
2014-12-09 2:47 ` Stefan Monnier
0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2014-12-08 20:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: ruediger, 16507
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 08 Dec 2014 13:51:21 -0500
> Cc: Rüdiger Sonderfeld <ruediger@c-plusplus.de>,
> 16507@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.
^ permalink raw reply [flat|nested] 31+ messages in thread
* bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon.
2014-12-08 20:41 ` Eli Zaretskii
@ 2014-12-09 2:47 ` Stefan Monnier
2016-11-13 23:52 ` bug#16507: 24.3; systemd unit for a GNU Emacs daemon Glenn Morris
0 siblings, 1 reply; 31+ messages in thread
From: Stefan Monnier @ 2014-12-09 2:47 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ruediger, 16507
>> >> 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
^ permalink raw reply [flat|nested] 31+ messages in thread