Merge branch 'db' into service
* db: 优化 精简MySQL连接日志命名空间 添加 MySQL连接是否enbale的配置处理 优化 Redis连接未启用时日志修改为警告
This commit is contained in:
@@ -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: '',
|
||||||
|
|||||||
@@ -9,9 +9,13 @@ import config from "../../config";
|
|||||||
|
|
||||||
class MySQLConnectPool {
|
class MySQLConnectPool {
|
||||||
private pool: any;
|
private pool: any;
|
||||||
private logger = new Logger('MySQLConnection');
|
private logger = new Logger('MySQL');
|
||||||
|
|
||||||
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 () => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class _RedisConnection {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (!config.redis.enable) {
|
if (!config.redis.enable) {
|
||||||
this.logger.info('Database is disabled, initialization terminated');
|
this.logger.warn('Database is disabled, initialization terminated');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user