添加 MySQL连接是否enbale的配置处理

This commit is contained in:
tone
2024-09-26 14:04:24 +08:00
parent 3a5161e73a
commit b13b0f4684
2 changed files with 5 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ const config = {
methods: ['GET', 'POST'] methods: ['GET', 'POST']
}, },
mysql: { mysql: {
enable: false,
host: 'localhost', host: 'localhost',
port: 3306, port: 3306,
database: '', database: '',

View File

@@ -12,6 +12,10 @@ class MySQLConnectPool {
private logger = new Logger('MySQLConnection'); private logger = new Logger('MySQLConnection');
constructor() { constructor() {
if(!config.mysql.enable){
this.logger.warn('Database is disabled, initialization terminated');
return;
}
this.pool = this.createConnectPool(); this.pool = this.createConnectPool();
this.logger.info("Database connection pool created") this.logger.info("Database connection pool created")
setTimeout(async () => { setTimeout(async () => {