Adds argument parsing & provides entrypoint for starting app

This commit is contained in:
Oleg Silkin 2019-07-24 01:44:26 -04:00
parent 99ff987dad
commit 6512ec78cd

View file

@ -1,6 +1,8 @@
import logging.config import logging.config
import logging import logging
import os import argparse
import sys
from src.settings import config from src.settings import config
from src.server.app import run_app from src.server.app import run_app
@ -68,7 +70,16 @@ def config_logging_from_settings(conf):
logging.config.dictConfig(_config) logging.config.dictConfig(_config)
if __name__ == '__main__': 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)
if args.port:
config['PORT'] = args.port
config_logging_from_settings(config) config_logging_from_settings(config)
logger = logging.getLogger(__name__)
run_app(config) run_app(config)
if __name__ == '__main__':
sys.exit(main())