- Added new PID lock file management

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@170 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.5
Cyril Jaquier 2005-08-04 20:51:14 +00:00
parent 9761d31f4b
commit 1fcf7612fd
1 changed files with 9 additions and 2 deletions

View File

@ -31,12 +31,16 @@ import sys, traceback, logging
# Appends our own modules path. # Appends our own modules path.
sys.path.append("/usr/lib/fail2ban") sys.path.append("/usr/lib/fail2ban")
# Now we can import our module. # Now we can import our modules.
import fail2ban import fail2ban
from utils.pidlock import PIDLock
# Gets the instance of the logger. # Get the instance of the logger.
logSys = logging.getLogger("fail2ban") logSys = logging.getLogger("fail2ban")
# Get PID lock file instance
pidLock = PIDLock()
# Start the application. Handle all the unhandled exceptions # Start the application. Handle all the unhandled exceptions
try: try:
fail2ban.main() fail2ban.main()
@ -44,10 +48,13 @@ except SystemExit:
# We called sys.exit(). Nothing wrong so just pass # We called sys.exit(). Nothing wrong so just pass
pass pass
except Exception, e: except Exception, e:
# Print the exception data
(type, value, tb) = sys.exc_info() (type, value, tb) = sys.exc_info()
tbStack = traceback.extract_tb(tb) tbStack = traceback.extract_tb(tb)
logSys.error("Fail2Ban got an unhandled exception and died.") logSys.error("Fail2Ban got an unhandled exception and died.")
logSys.error("Type: " + `type.__name__` + "\n" + logSys.error("Type: " + `type.__name__` + "\n" +
"Value: " + `e.args` + "\n" + "Value: " + `e.args` + "\n" +
"TB: " + `tbStack`) "TB: " + `tbStack`)
# Remove the PID lock file. Should close #1239562
pidLock.remove()
logging.shutdown() logging.shutdown()