summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2008-11-02 09:36:58 +0000
committerUlrich Müller <ulm@gentoo.org>2008-11-02 09:36:58 +0000
commitb6fd8f74326c60ee272bbf7a8040714d05f3e808 (patch)
tree371302ed4a4204c4ebe0f4da55f10b823fabf4b8
parentPidfile support. (diff)
downloademacs-b6fd8f74326c60ee272bbf7a8040714d05f3e808.tar.gz
emacs-b6fd8f74326c60ee272bbf7a8040714d05f3e808.tar.bz2
emacs-b6fd8f74326c60ee272bbf7a8040714d05f3e808.zip
Write process id to file.
svn path=/emacs-overlay/; revision=1193
-rw-r--r--app-emacs/emacs-daemon/ChangeLog7
-rw-r--r--app-emacs/emacs-daemon/Manifest7
-rw-r--r--app-emacs/emacs-daemon/emacs-daemon-0.3.ebuild (renamed from app-emacs/emacs-daemon/emacs-daemon-0.2.ebuild)7
-rw-r--r--app-emacs/emacs-daemon/files/10emacs-daemon-gentoo.el12
-rw-r--r--app-emacs/emacs-daemon/files/emacs-daemon.rc16
5 files changed, 41 insertions, 8 deletions
diff --git a/app-emacs/emacs-daemon/ChangeLog b/app-emacs/emacs-daemon/ChangeLog
index f596889..3ef1c57 100644
--- a/app-emacs/emacs-daemon/ChangeLog
+++ b/app-emacs/emacs-daemon/ChangeLog
@@ -2,6 +2,13 @@
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
+*emacs-daemon-0.3 (02 Nov 2008)
+
+ 02 Nov 2008; Ulrich Mueller <ulm@gentoo.org>
+ +files/10emacs-daemon-gentoo.el, files/emacs-daemon.rc,
+ -emacs-daemon-0.2.ebuild, +emacs-daemon-0.3.ebuild:
+ Write process id to file.
+
*emacs-daemon-0.2 (29 Oct 2008)
29 Oct 2008; Ulrich Mueller <ulm@gentoo.org> -files/emacs-daemon.conf,
diff --git a/app-emacs/emacs-daemon/Manifest b/app-emacs/emacs-daemon/Manifest
index 035f5fa..f3edf83 100644
--- a/app-emacs/emacs-daemon/Manifest
+++ b/app-emacs/emacs-daemon/Manifest
@@ -1,4 +1,5 @@
-AUX emacs-daemon.rc 1120 RMD160 06704b95a4aabbdbf6e249e4fd300b00b3f0307f SHA1 af909fef80fa8d10c08fbdd194d595c673878575 SHA256 dfba684f5899607c8d966a903511920156f3d70da1d2608e1ae0ceccafb15da2
-EBUILD emacs-daemon-0.2.ebuild 830 RMD160 a259a589dd0ed4551ee97c585f7d40bd1946abf7 SHA1 d78d15eeddb15e15e46fbc19d203fe739d3c64aa SHA256 21cbb84adf04f2200f242d7d732026dbf991b238074afe10f6dbfb1161b054e3
-MISC ChangeLog 690 RMD160 544295c5eb856bc7a95cd12f0362e8cd08b15441 SHA1 1852a602f06f164df54a0c3f0ad977279db84612 SHA256 f309a7d627c3ea8690e95536c3d2686dc5c0468405e973e2763fdc3e359e2ec8
+AUX 10emacs-daemon-gentoo.el 310 RMD160 44d1732cc476e0e3b8f7db5b1fcf2535cc33341e SHA1 94c1488050e043a674dd95448383c9a8a9bd918d SHA256 f4437e9ec33c87a8bf8b54d37489efef4491fdeaa9558528d9ea5e0fdb9f7a5c
+AUX emacs-daemon.rc 1510 RMD160 c6ee30b530cf40b1f7eae8446637591a77c36db8 SHA1 7b28a96197e19018b03214f76987c6136feb3a21 SHA256 99af924ca961c2f21070312de041e6a21a9a38488603004048a8272bfafe1326
+EBUILD emacs-daemon-0.3.ebuild 903 RMD160 96bd56cd69bb3412616a6fc4675d4ee6e87bf5ef SHA1 e7a63b38b431c9d44decb54df6bef40c374623b9 SHA256 bee5ac4de829079620ab8a7f79721dda7671c49664f5e3b4edc3b8adba54f25d
+MISC ChangeLog 911 RMD160 a118a8d8df4717ef1591e01f94a76e71fabf429d SHA1 9fd103f3fbdd5b03b4c1a084f68dcd8c3b776fd9 SHA256 09db5d0a537936c15cdc64309d4775ab40d7c37b13ebec8681965faadd3c2da8
MISC metadata.xml 158 RMD160 415d172437ca754d24fc5ab186ba8e77934d96e4 SHA1 61f6eff9729cd87a725c2a70c81aca4270a17fc4 SHA256 1393bdef3a74343fdb40a112c7096a1af16f67e7a43413250de28dfe73810eab
diff --git a/app-emacs/emacs-daemon/emacs-daemon-0.2.ebuild b/app-emacs/emacs-daemon/emacs-daemon-0.3.ebuild
index 02d6635..1d6844a 100644
--- a/app-emacs/emacs-daemon/emacs-daemon-0.2.ebuild
+++ b/app-emacs/emacs-daemon/emacs-daemon-0.3.ebuild
@@ -2,6 +2,8 @@
# Distributed under the terms of the GNU General Public License v2
# $Header: $
+inherit elisp-common
+
DESCRIPTION="Support files for Emacs daemon started as rc service"
HOMEPAGE="http://www.gentoo.org/proj/en/lisp/emacs/"
SRC_URI=""
@@ -15,10 +17,10 @@ DEPEND=">=virtual/emacs-23"
RDEPEND="${DEPEND}
>=sys-apps/openrc-0.3.0-r1"
-EMACS="/usr/bin/emacs"
+SITEFILE=10${PN}-gentoo.el
pkg_setup() {
- local has_daemon=$(${EMACS} -batch -q --no-site-file \
+ local has_daemon=$(${EMACS} ${EMACSFLAGS} \
--eval "(princ (fboundp 'daemonp))")
if [ "${has_daemon}" != t ]; then
ewarn "The current Emacs version does not support running as a daemon"
@@ -28,5 +30,6 @@ pkg_setup() {
}
src_install() {
+ elisp-site-file-install "${FILESDIR}/${SITEFILE}" || die
newinitd "${FILESDIR}/emacs-daemon.rc" emacs-daemon || die
}
diff --git a/app-emacs/emacs-daemon/files/10emacs-daemon-gentoo.el b/app-emacs/emacs-daemon/files/10emacs-daemon-gentoo.el
new file mode 100644
index 0000000..ae29057
--- /dev/null
+++ b/app-emacs/emacs-daemon/files/10emacs-daemon-gentoo.el
@@ -0,0 +1,12 @@
+
+;;; emacs-daemon site-lisp configuration
+
+(and
+ (fboundp 'daemonp)
+ (daemonp)
+ (let ((file (concat "/var/run/emacs-daemon/"
+ (user-login-name) "/emacs.pid")))
+ (if (file-writable-p file)
+ ;; write process id to file
+ (with-temp-file file
+ (insert (number-to-string (emacs-pid)) "\n")))))
diff --git a/app-emacs/emacs-daemon/files/emacs-daemon.rc b/app-emacs/emacs-daemon/files/emacs-daemon.rc
index 59f9b9b..63d5a1b 100644
--- a/app-emacs/emacs-daemon/files/emacs-daemon.rc
+++ b/app-emacs/emacs-daemon/files/emacs-daemon.rc
@@ -4,7 +4,9 @@
# Distributed under the terms of the GNU General Public License v2
EMACS="/usr/bin/emacs"
-USER=${RC_SVCNAME#*.}
+USER="${RC_SVCNAME#*.}"
+PIDFILE_DIR="/var/run/emacs-daemon/${USER}"
+PIDFILE="${PIDFILE_DIR}/emacs.pid"
checkconfig() {
if [ "${USER}" = "${RC_SVCNAME}" ]; then
@@ -18,6 +20,8 @@ checkconfig() {
return 1
fi
+ # Executing Emacs here also ensures a warm cache, which later helps
+ # to create the pid file in a timely manner (within 0.5 seconds).
local has_daemon=$(${EMACS} -batch -q --no-site-file \
--eval "(princ (fboundp 'daemonp))")
if [ "${has_daemon}" != t ]; then
@@ -25,6 +29,12 @@ checkconfig() {
return 1
fi
+ if [ ! -d "${PIDFILE_DIR}" ]; then
+ ewarn "${PIDFILE_DIR} does not exist - creating it"
+ mkdir -p "${PIDFILE_DIR}"
+ chown "${USER}" "${PIDFILE_DIR}"
+ fi
+
return 0
}
@@ -35,13 +45,13 @@ start() {
ebegin "Starting Emacs daemon for ${USER}"
eval home="~${USER}"
start-stop-daemon --start --user "${USER}" --chdir "${home}" \
- --quiet --name emacs-daemon --exec "${EMACS}" -- --daemon
+ --quiet --pidfile "${PIDFILE}" --exec "${EMACS}" -- --daemon
eend $?
}
stop() {
ebegin "Stopping Emacs daemon for ${USER}"
start-stop-daemon --stop --user "${USER}" \
- --name emacs-daemon --exec "${EMACS}"
+ --pidfile "${PIDFILE}" --exec "${EMACS}"
eend $?
}