维护:修改维护启动逻辑,扩展服也能正常获取
This commit is contained in:
+23
-6
@@ -30,7 +30,6 @@ import { resResult, genCode } from './app/pubUtils/util';
|
||||
import { errlogger, infologger, loadLogger } from './app/util/logger';
|
||||
import { connectThinkingData, getTire } from './app/services/sdkService';
|
||||
import { loadGmDb } from './app/db';
|
||||
const fs = require('fs');
|
||||
|
||||
const filePath = (_pinus as any).FILEPATH;
|
||||
filePath.MASTER = '/config/master';
|
||||
@@ -66,14 +65,12 @@ app.configure(function () {
|
||||
app.loadConfig('database', app.getBase() + '/config/database');
|
||||
console.log('env:', app.get('env'));
|
||||
console.log('db:', app.get('database'));
|
||||
|
||||
initMongodb(app);
|
||||
initGmMongodb(app);
|
||||
initRedis(app);
|
||||
|
||||
setupRoutes(app);
|
||||
setupFilters(app);
|
||||
connectThinkingData(app);
|
||||
loadLogger(app.getServerId())
|
||||
loadLogger(app.getServerId());
|
||||
treatStartLogic(app);
|
||||
|
||||
app.set(RESERVED.ERROR_HANDLER, errorHandler);
|
||||
app.set(RESERVED.GLOBAL_ERROR_HANDLER, globalErrorHandler);
|
||||
@@ -192,6 +189,26 @@ export function globalErrorHandler(err: Error, msg: any, resp: any,
|
||||
}
|
||||
}
|
||||
|
||||
async function treatStartLogic(app: _pinus.Application) {
|
||||
await connectDb(app);
|
||||
console.log('treatStartLogic', app.getServerType());
|
||||
if(app.getServerType() == 'systimer') {
|
||||
// 维护信息
|
||||
await timeTaskService.initMaintenance();
|
||||
} else {
|
||||
await timeTaskService.initMaintenanaceInOtherServers();
|
||||
}
|
||||
}
|
||||
|
||||
async function connectDb(app: _pinus.Application) {
|
||||
// Promise并行处理
|
||||
return Promise.all([
|
||||
initMongodb(app),
|
||||
initGmMongodb(app),
|
||||
initRedis(app)
|
||||
])
|
||||
}
|
||||
|
||||
async function initMongodb(app: _pinus.Application) {
|
||||
await mongoose.connect(app.get('database').mongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }, (err) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user