msys2-web/run.py
Christoph Reiter b2843b55f1 Some more logging
configure the root logger to log INFO for all loggers to stdout and
add our own logger which logs from DEBUG and up.
2023-08-19 23:43:21 +02:00

36 lines
960 B
Python
Executable File

# Copyright 2016-2020 Christoph Reiter
# SPDX-License-Identifier: MIT
import os
import sys
import argparse
from typing import List, Optional, Union
import uvicorn
from app import app
from app import appconfig
from app import logger
def main(argv: List[str]) -> Optional[Union[int, str]]:
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--cache", action="store_true",
help="use local repo cache")
parser.add_argument("-p", "--port", type=int, default=8160,
help="port number")
args = parser.parse_args()
if args.cache:
base = os.path.dirname(os.path.realpath(__file__))
cache_dir = os.path.join(base, ".app.cache")
logger.info(f"Using cache: {repr(cache_dir)}")
appconfig.CACHE_DIR = cache_dir
uvicorn.run(app, host="127.0.0.1", port=args.port, log_config=None)
return None
if __name__ == "__main__":
sys.exit(main(sys.argv))