2019-07-20 15:06:34 +02:00
|
|
|
import logging.config
|
|
|
|
import logging
|
2019-07-24 07:44:26 +02:00
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
|
2019-07-20 15:06:34 +02:00
|
|
|
from src.settings import config
|
2019-07-24 07:43:50 +02:00
|
|
|
from src.server.app import run_app
|
2019-05-30 00:01:48 +02:00
|
|
|
|
2019-07-20 15:06:34 +02:00
|
|
|
|
|
|
|
def config_logging_from_settings(conf):
|
|
|
|
_config = {
|
|
|
|
"version": 1,
|
|
|
|
"disable_existing_loggers": False,
|
|
|
|
"formatters": {
|
|
|
|
"standard": {
|
|
|
|
"format": conf['LOGGING']['FORMAT'],
|
|
|
|
"datefmt": conf['LOGGING']['DATEFMT']
|
|
|
|
},
|
|
|
|
"aiohttp": {
|
2019-07-30 06:29:26 +02:00
|
|
|
"format": conf['LOGGING']['AIOHTTP_FORMAT'],
|
2019-07-20 15:06:34 +02:00
|
|
|
"datefmt": conf['LOGGING']['DATEFMT']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"handlers": {
|
|
|
|
"console": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"formatter": "standard",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"stream": "ext://sys.stdout"
|
|
|
|
},
|
|
|
|
"debug": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"formatter": "standard",
|
|
|
|
"class": "logging.handlers.RotatingFileHandler",
|
|
|
|
"filename": conf['PATH']['DEBUG_LOG'],
|
|
|
|
"maxBytes": 10485760,
|
|
|
|
"backupCount": 5
|
|
|
|
},
|
|
|
|
"error": {
|
|
|
|
"level": "ERROR",
|
|
|
|
"formatter": "standard",
|
|
|
|
"class": "logging.handlers.RotatingFileHandler",
|
|
|
|
"filename": conf['PATH']['ERROR_LOG'],
|
|
|
|
"maxBytes": 10485760,
|
|
|
|
"backupCount": 5
|
|
|
|
},
|
|
|
|
"server": {
|
|
|
|
"level": "NOTSET",
|
|
|
|
"formatter": "aiohttp",
|
|
|
|
"class": "logging.handlers.RotatingFileHandler",
|
|
|
|
"filename": conf['PATH']['SERVER_LOG'],
|
|
|
|
"maxBytes": 10485760,
|
|
|
|
"backupCount": 5
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"": {
|
|
|
|
"handlers": ["console", "debug", "error"],
|
|
|
|
"level": "DEBUG",
|
|
|
|
"propogate": True
|
|
|
|
},
|
|
|
|
"aiohttp.access": {
|
|
|
|
"handlers": ["server"],
|
|
|
|
"level": "INFO",
|
|
|
|
"propogate": False
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
logging.config.dictConfig(_config)
|
|
|
|
|
|
|
|
|
2019-07-24 07:44:26 +02:00
|
|
|
def main(argv=None):
|
|
|
|
argv = argv or sys.argv[1:]
|
|
|
|
parser = argparse.ArgumentParser(description='LBRY Comment Server')
|
|
|
|
parser.add_argument('--port', type=int)
|
|
|
|
args = parser.parse_args(argv)
|
2019-07-30 06:14:42 +02:00
|
|
|
config_logging_from_settings(config)
|
2019-07-24 07:44:26 +02:00
|
|
|
if args.port:
|
|
|
|
config['PORT'] = args.port
|
2019-07-20 15:06:34 +02:00
|
|
|
config_logging_from_settings(config)
|
2019-07-24 07:44:26 +02:00
|
|
|
run_app(config)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|