]> code.delx.au - gnu-emacs/blobdiff - doc/emacs/misc.texi
Merge from origin/emacs-25
[gnu-emacs] / doc / emacs / misc.texi
index 853b97849201c675c432de0ea814324e0ea3d390..94e1f198f2b6869f7c4eeb2ae3e93b5dd9bd7517 100644 (file)
@@ -1580,6 +1580,44 @@ option.  @xref{Initial Options}.  When Emacs is started this way, it
 calls @code{server-start} after initialization, and returns control to
 the calling terminal instead of opening an initial frame; it then
 waits in the background, listening for edit requests.
+
+@cindex socket activation, systemd, Emacs
+@item
+An external process can invoke the Emacs server when a connection
+event occurs upon a specified socket and pass the socket to the new
+Emacs server process.  An instance of this is @command{systemd}'s
+socket functionality: the @command{systemd} service creates a socket and
+listens for connections on it; when @command{emacsclient} connects to
+it for the first time, @command{systemd} can launch the Emacs server
+and hand over the socket to it for servicing @command{emacsclient}
+connections.  A setup to use this functionality could be:
+
+@file{~/.config/systemd/user/emacs.service}:
+@example
+[Unit]
+Description=Emacs
+
+[Service]
+Type=forking
+ExecStart=/path/to/emacs --daemon
+ExecStop=/path/to/emacsclient --eval "(kill-emacs)"
+Restart=always
+
+[Install]
+WantedBy=default.target
+@end example
+
+@file{~/.config/systemd/user/emacs.socket}:
+@example
+[Socket]
+ListenStream=/path/to/.emacs.socket
+
+[Install]
+WantedBy=sockets.target
+@end example
+
+The @code{ListenStream} path will be the path that Emacs listens for
+connections from @command{emacsclient}; this is a file of your choice.
 @end itemize
 
 @cindex @env{TEXEDIT} environment variable