From 63934aa187d33df51c96207f882ed03b8ab931ad Mon Sep 17 00:00:00 2001 From: Shaowen Yin Date: Wed, 6 Nov 2024 17:49:16 +0800 Subject: [PATCH] server: fix crash when any webserver dependency is not installed (#877) Before, when a user enables webserver and does not install sanic, the app just crashes. Now, log an error log. --- feeluown/app/server_app.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/feeluown/app/server_app.py b/feeluown/app/server_app.py index 858cdbf685..d815f5ac7f 100644 --- a/feeluown/app/server_app.py +++ b/feeluown/app/server_app.py @@ -52,7 +52,11 @@ def run(self): self.config.PUBSUB_PORT, )) if self.config.ENABLE_WEB_SERVER: - from feeluown.webserver import run_web_server - asyncio.create_task( - run_web_server(self.get_listen_addr(), self.config.WEB_PORT)) + try: + from feeluown.webserver import run_web_server + except ImportError as e: + logger.error(f"can't enable webserver, err: {e}") + else: + asyncio.create_task( + run_web_server(self.get_listen_addr(), self.config.WEB_PORT)) asyncio.create_task(run_nowplaying_server(self))