clean sys.exit

This commit is contained in:
petrucci4prez 2017-05-23 01:43:39 -04:00
parent cb15250efd
commit 1cfb86d705
2 changed files with 6 additions and 5 deletions

View File

@ -36,7 +36,7 @@ def clean():
def sigtermHandler(signum, stackFrame): def sigtermHandler(signum, stackFrame):
logger.info('Caught SIGTERM') logger.info('Caught SIGTERM')
exit() raise SystemExit
class ResourceManager(BaseManager): class ResourceManager(BaseManager):
def __init__(self): def __init__(self):

View File

@ -1,4 +1,4 @@
import logging, os, sys import logging, os
from subprocess import run, PIPE, CalledProcessError from subprocess import run, PIPE, CalledProcessError
from logging.handlers import TimedRotatingFileHandler, QueueListener, QueueHandler from logging.handlers import TimedRotatingFileHandler, QueueListener, QueueHandler
@ -43,7 +43,7 @@ class GlusterFS():
# active, so use fallback to get the explicit mount errors # active, so use fallback to get the explicit mount errors
stderr=e.stderr.decode('ascii').rstrip() stderr=e.stderr.decode('ascii').rstrip()
fallbackLogger(__name__, 'CRITICAL', stderr) fallbackLogger(__name__, 'CRITICAL', stderr)
sys.exit() raise SystemExit
class MasterLogger(): class MasterLogger():
def __init__(self, name, level, queue): def __init__(self, name, level, queue):
@ -63,8 +63,9 @@ class MasterLogger():
if not os.path.exists(logdest): if not os.path.exists(logdest):
os.mkdir(logdest) os.mkdir(logdest)
elif os.path.isfile(logdest): elif os.path.isfile(logdest):
fallbackLogger(__name__, 'CRITICAL', '{} is present but is a file (vs a directory). Please (re)move this file to prevent data loss'.format(logdest)) fallbackLogger(__name__, 'CRITICAL', '{} is present but is a file (vs a directory). ' \
sys.exit() 'Please (re)move this file to prevent data loss'.format(logdest))
raise SystemExit
self.rotatingFile = TimedRotatingFileHandler(logdest + '/pyledriver-log', when='midnight') self.rotatingFile = TimedRotatingFileHandler(logdest + '/pyledriver-log', when='midnight')
self.rotatingFile.setFormatter(fileFormat) self.rotatingFile.setFormatter(fileFormat)