import argparse import logging import coloredlogs from sorteerhoed.central_management import CentralManagement if __name__ == '__main__': argParser = argparse.ArgumentParser( description='Start up the Sorteerhoed server') argParser.add_argument( '--config', '-c', required=True, type=str, help='The yaml config file to load' ) argParser.add_argument( '--no-plotter', action='store_true', help='Skip attempt to connect to plotter' ) argParser.add_argument( '--autostart', action='store_true', help='Don\'t require a visit to the control panel to start the first hit. Usefull when you know plotter & scanner are already set up' ) argParser.add_argument( '--for-real', action='store_true', help='Do not use sandbox' ) argParser.add_argument( '--verbose', '-v', action='count', default=0 ) args = argParser.parse_args() loglevel = logging.NOTSET if args.verbose > 1 else logging.DEBUG if args.verbose > 0 else logging.INFO coloredlogs.install( level=loglevel, # default: "%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s" fmt="%(asctime)s %(hostname)s %(name)s[%(process)d,%(threadName)s] %(levelname)s %(message)s" ) # File logging formatter = logging.Formatter(fmt='%(asctime)s %(module)s:%(lineno)d %(levelname)8s | %(message)s', datefmt='%Y/%m/%d %H:%M:%S') # %I:%M:%S %p AM|PM format logFileHandler = logging.handlers.RotatingFileHandler( 'mt_server.log', maxBytes=1024*512, backupCount=5 ) logFileHandler.setFormatter(formatter) logger = logging.getLogger("sorteerhoed") logger.addHandler( logFileHandler ) logger.info("Start server") command = CentralManagement(debug_mode=args.verbose > 0) command.loadConfig(args.config, args) command.start()