From 233815932553bdf9781e6bbde9976abfe458b93a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 4 Apr 2020 13:36:13 +0200 Subject: sshban: log uncaught top-level exception Makes it more noticeable when sshban dies. --- sshban.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sshban.py') diff --git a/sshban.py b/sshban.py index 0479764..dd2a5f2 100755 --- a/sshban.py +++ b/sshban.py @@ -177,6 +177,11 @@ for h in handlers: h.setFormatter(formatter) logger.addHandler(h) +# log uncaught top-level exception +def excepthook(t, v, tb, logger = logger): + logger.error('Uncaught top-level exception', exc_info = (t, v, tb)) +sys.excepthook = excepthook + judge = Judge({ ACT_BAN_SHORT : args.thresh_short, ACT_BAN_MEDIUM : args.thresh_medium, ACT_BAN_LONG : args.thresh_long }) # open FIFO read-write so poll() won't return HUP endlessly if the writer dies -- cgit v1.2.3