Fix status bug.

Fix log level of uvicorn access.
This commit is contained in:
EstrellaXD
2023-05-11 16:38:38 +08:00
parent cd9e4fda70
commit fb6414f2e3
4 changed files with 17 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
import os
import logging
import uvicorn
@@ -8,22 +7,22 @@ from module.conf import settings, setup_logger
log_level = logging.DEBUG if settings.log.debug_enable else logging.INFO
setup_logger(log_level, reset=True)
logger = logging.getLogger(__name__)
uvicorn_logging_config = {
"version": 1,
"disable_existing_loggers": False,
"handlers": logger.handlers,
"loggers": {
"uvicorn": {
"level": log_level,
},
}}
"uvicorn": {
"level": log_level,
},
"uvicorn.access": {
"level": "WARNING",
},
}
}
if __name__ == "__main__":
uvicorn.run(
router, host="0.0.0.0", port=settings.program.webui_port,
log_config=uvicorn_logging_config,
)

View File

@@ -18,7 +18,7 @@ async def update_config(config: Config):
try:
settings.save(config_dict=config.dict())
logger.info("Config updated")
return {"status": "Success"}
return {"message": "Success"}
except Exception as e:
logger.warning(e)
return {"status": "Failed to update config"}
return {"message": "Failed to update config"}

View File

@@ -56,17 +56,17 @@ async def shutdown_program():
# Check status
@router.get("/api/v1/check/downloader", tags=["program"])
@router.get("/api/v1/check/downloader", tags=["check"])
async def check_downloader_status():
return check_downloader()
@router.get("/api/v1/check/rss", tags=["program"])
@router.get("/api/v1/check/rss", tags=["check"])
async def check_rss_status():
return check_rss()
@router.get("/api/v1/check", tags=["program"])
@router.get("/api/v1/check", tags=["check"])
async def check_all():
return check_status()

View File

@@ -95,8 +95,10 @@ def first_run():
async def start_program():
global rss_thread, rename_thread
start_info()
if check_status():
# First init
if not check_status():
stop_event.set()
logger.info("Program paused.")
else:
first_run()
with BangumiDatabase() as database:
database.update_table()