mirror of https://github.com/fail2ban/fail2ban
- Removed log4py dependency
- Catch the unhandled exceptions git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@165 a942ae1a-1317-0410-a47c-b1dcaea8d6050.5
parent
c2d30a29de
commit
5a38a2563c
36
fail2ban
36
fail2ban
|
@ -26,22 +26,28 @@ __date__ = "$Date$"
|
|||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||
__license__ = "GPL"
|
||||
|
||||
from sys import exit, path
|
||||
import sys, traceback, logging
|
||||
|
||||
# Appends our own modules path. Added before log4py import
|
||||
# because log4py could be distributed with Fail2Ban.
|
||||
path.append("/usr/lib/fail2ban")
|
||||
# Appends our own modules path.
|
||||
sys.path.append("/usr/lib/fail2ban")
|
||||
|
||||
# Checks for required libs
|
||||
# Checks if log4py is present.
|
||||
try:
|
||||
import log4py
|
||||
except:
|
||||
print "log4py is needed (see README)"
|
||||
exit(-1)
|
||||
|
||||
# Now we can import our module
|
||||
# Now we can import our module.
|
||||
import fail2ban
|
||||
|
||||
# Start the application
|
||||
fail2ban.main()
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban")
|
||||
|
||||
# Start the application. Handle all the unhandled exceptions
|
||||
try:
|
||||
fail2ban.main()
|
||||
except SystemExit:
|
||||
# We called sys.exit(). Nothing wrong so just pass
|
||||
pass
|
||||
except Exception, e:
|
||||
(type, value, tb) = sys.exc_info()
|
||||
tbStack = traceback.extract_tb(tb)
|
||||
logSys.error("Fail2Ban got an unhandled exception and died.")
|
||||
logSys.error("Type: " + `type.__name__` + "\n" +
|
||||
"Value: " + `e.args` + "\n" +
|
||||
"TB: " + `tbStack`)
|
||||
logging.shutdown()
|
||||
|
|
Loading…
Reference in New Issue