guest_worker/sorteerhoed.py

69 lines
2 KiB
Python
Raw Normal View History

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