Рефакторинг
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const Logger = require('./Logger');
|
const Logger = require('./Logger');
|
||||||
const configManager = new (require('../config'))();//singleton
|
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|
||||||
@@ -15,11 +14,10 @@ class AppLogger {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init(config) {
|
||||||
if (this.inited)
|
if (this.inited)
|
||||||
throw new Error('already inited');
|
throw new Error('already inited');
|
||||||
|
|
||||||
let config = configManager.config;
|
|
||||||
let loggerParams = null;
|
let loggerParams = null;
|
||||||
|
|
||||||
if (config.loggingEnabled) {
|
if (config.loggingEnabled) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
const SqliteConnectionPool = require('./SqliteConnectionPool');
|
const SqliteConnectionPool = require('./SqliteConnectionPool');
|
||||||
const configManager = new (require('../config'))();//singleton
|
|
||||||
const log = new (require('../core/AppLogger'))().log;//singleton
|
const log = new (require('../core/AppLogger'))().log;//singleton
|
||||||
|
|
||||||
const migrations = {
|
const migrations = {
|
||||||
@@ -24,7 +23,7 @@ class ConnManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init(config) {
|
async init(config) {
|
||||||
this.config = configManager.config;
|
this.config = config;
|
||||||
this._pool = {};
|
this._pool = {};
|
||||||
|
|
||||||
const force = null;//(config.branch == 'development' ? 'last' : null);
|
const force = null;//(config.branch == 'development' ? 'last' : null);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ async function init() {
|
|||||||
|
|
||||||
//logger
|
//logger
|
||||||
const appLogger = new (require('./core/AppLogger'))();//singleton
|
const appLogger = new (require('./core/AppLogger'))();//singleton
|
||||||
await appLogger.init();
|
await appLogger.init(config);
|
||||||
const log = appLogger.log;
|
const log = appLogger.log;
|
||||||
|
|
||||||
//dirs
|
//dirs
|
||||||
@@ -37,7 +37,7 @@ async function init() {
|
|||||||
|
|
||||||
//connections
|
//connections
|
||||||
const connManager = new (require('./db/ConnManager'))();//singleton
|
const connManager = new (require('./db/ConnManager'))();//singleton
|
||||||
await connManager.init();
|
await connManager.init(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user