From 3a5161e73a43509b106efbbb4532e99daf0a78ae Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Thu, 26 Sep 2024 14:02:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Redis=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=9C=AA=E5=90=AF=E7=94=A8=E6=97=B6=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/Database/RedisConnection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Database/RedisConnection.ts b/src/lib/Database/RedisConnection.ts index b8a7b4c..bb946af 100644 --- a/src/lib/Database/RedisConnection.ts +++ b/src/lib/Database/RedisConnection.ts @@ -8,7 +8,7 @@ class _RedisConnection { constructor() { if (!config.redis.enable) { - this.logger.info('Database is disabled, initialization terminated'); + this.logger.warn('Database is disabled, initialization terminated'); return; } From b13b0f468420fc4f5242e9affc171bcdfab03024 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Thu, 26 Sep 2024 14:04:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20MySQL=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=98=AF=E5=90=A6enbale=E7=9A=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.ts | 1 + src/lib/Database/MySQLConnection.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/config.ts b/src/config.ts index 285d6ea..e01988b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,6 +5,7 @@ const config = { methods: ['GET', 'POST'] }, mysql: { + enable: false, host: 'localhost', port: 3306, database: '', diff --git a/src/lib/Database/MySQLConnection.ts b/src/lib/Database/MySQLConnection.ts index b72b181..f4fd8e7 100644 --- a/src/lib/Database/MySQLConnection.ts +++ b/src/lib/Database/MySQLConnection.ts @@ -12,6 +12,10 @@ class MySQLConnectPool { private logger = new Logger('MySQLConnection'); constructor() { + if(!config.mysql.enable){ + this.logger.warn('Database is disabled, initialization terminated'); + return; + } this.pool = this.createConnectPool(); this.logger.info("Database connection pool created") setTimeout(async () => { From 6d7cf35c42eb7038dde632fe6ead1e936883c183 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Thu, 26 Sep 2024 14:04:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=B2=BE=E7=AE=80MySQ?= =?UTF-8?q?L=E8=BF=9E=E6=8E=A5=E6=97=A5=E5=BF=97=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/Database/MySQLConnection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Database/MySQLConnection.ts b/src/lib/Database/MySQLConnection.ts index f4fd8e7..b98de9c 100644 --- a/src/lib/Database/MySQLConnection.ts +++ b/src/lib/Database/MySQLConnection.ts @@ -9,7 +9,7 @@ import config from "../../config"; class MySQLConnectPool { private pool: any; - private logger = new Logger('MySQLConnection'); + private logger = new Logger('MySQL'); constructor() { if(!config.mysql.enable){