guest_worker/sorteerhoed.py

64 lines
1.8 KiB
Python
Raw Normal View History

2019-10-23 08:56:28 +00:00
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'
)
2019-11-02 20:23:38 +00:00
argParser.add_argument(
'--for-real',
action='store_true',
help='Do not use sandbox'
)
2019-10-23 08:56:28 +00:00
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)
2019-10-23 08:56:28 +00:00
command.start()