[packages/python-dkimpy-milter] - take care of stale pid files, daemon requires fork

hawk hawk at pld-linux.org
Sun May 29 20:16:46 CEST 2022


commit 9f1adb0c02cb8172770f1eb639046f87bf76b2dc
Author: Marcin Krol <hawk at tld-linux.org>
Date:   Sun May 29 20:16:05 2022 +0200

    - take care of stale pid files, daemon requires fork

 dkimpy-milter.init | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/dkimpy-milter.init b/dkimpy-milter.init
index ce24462..3f6c882 100644
--- a/dkimpy-milter.init
+++ b/dkimpy-milter.init
@@ -30,9 +30,6 @@ else
 	exit 0
 fi
 
-# Get service config - may override defaults
-[ -f /etc/sysconfig/dkimpy-milter ] && . /etc/sysconfig/dkimpy-milter
-
 start() {
 	# Check if the service is already running?
 	if [ -f /var/lock/subsys/dkimpy-milter ]; then
@@ -40,8 +37,16 @@ start() {
 		return
 	fi
 
+	# Clean up stale pid file
+	if [ -f /var/run/dkimpy-milter.pid ]; then
+		pid=`cat /var/run/dkimpy-milter.pid`
+		if ! ps -p "$pid" >/dev/null 2>&1; then
+			rm -f /var/run/dkimpy-milter.pid
+		fi
+	fi
+
 	msg_starting "DKIM Milter"
-	daemon /usr/sbin/dkimpy-milter
+	daemon --fork /usr/sbin/dkimpy-milter
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dkimpy-milter
 }
@@ -55,7 +60,7 @@ stop() {
 	# Stop daemons.
 	msg_stopping "DKIM Milter"
 	killproc dkimpy-milter
-	rm -f /var/lock/subsys/dkimpy-milter
+	rm -f /var/lock/subsys/dkimpy-milter /var/run/dkimpy-milter.pid
 }
 
 condrestart() {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-dkimpy-milter.git/commitdiff/9f1adb0c02cb8172770f1eb639046f87bf76b2dc



More information about the pld-cvs-commit mailing list