From b174a2e8585678b8bb1d4dd7a0a678fce1f93fcf Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 13 Mar 2008 21:40:16 +0000 Subject: [PATCH] - Fixed PID file while started in daemon mode. Thanks to Christian Jobic who submitted a similar patch. git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_8@680 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- ChangeLog | 2 ++ server/server.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4983803ce..06173d066 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ ver. 0.8.3 (2008/??/??) - stable Thanks to Yaroslav Halchenko. - Fixed socket path in redhat and suse init script. Thanks to Jim Wight. +- Fixed PID file while started in daemon mode. Thanks to + Christian Jobic who submitted a similar patch. ver. 0.8.2 (2008/03/06) - stable ---------- diff --git a/server/server.py b/server/server.py index f363ca6e6..7a6640f3f 100644 --- a/server/server.py +++ b/server/server.py @@ -59,15 +59,6 @@ class Server: def start(self, sock, force = False): logSys.info("Starting Fail2ban v" + version.version) - # Creates a PID file. - try: - logSys.debug("Creating PID file %s" % Server.PID_FILE) - pidFile = open(Server.PID_FILE, 'w') - pidFile.write("%s\n" % os.getpid()) - pidFile.close() - except IOError, e: - logSys.error("Unable to create PID file: %s" % e) - # Install signal handlers signal.signal(signal.SIGTERM, self.__sigTERMhandler) signal.signal(signal.SIGINT, self.__sigTERMhandler) @@ -81,6 +72,16 @@ class Server: else: logSys.error("Could not create daemon") raise ServerInitializationError("Could not create daemon") + + # Creates a PID file. + try: + logSys.debug("Creating PID file %s" % Server.PID_FILE) + pidFile = open(Server.PID_FILE, 'w') + pidFile.write("%s\n" % os.getpid()) + pidFile.close() + except IOError, e: + logSys.error("Unable to create PID file: %s" % e) + # Start the communication logSys.debug("Starting communication") try: