后台:军团管理
This commit is contained in:
@@ -2,6 +2,7 @@ import 'reflect-metadata'
|
||||
import * as mongoose from 'mongoose';
|
||||
import { Application, IBoot } from 'egg';
|
||||
import { loadGmDb } from '@db/index';
|
||||
import { connectRedis } from '@pubUtils/redis';
|
||||
|
||||
export default class FooBoot implements IBoot {
|
||||
private readonly app: Application;
|
||||
@@ -16,6 +17,7 @@ export default class FooBoot implements IBoot {
|
||||
// this is the last chance to modify the config.
|
||||
await this.connectDB(this.app)
|
||||
await this.connectGMDB(this.app);
|
||||
await this.connectRedis(this.app);
|
||||
|
||||
this.app.config.realEnv = this.app.config.env;
|
||||
if(this.app.config.env == 'local') {
|
||||
@@ -78,6 +80,13 @@ export default class FooBoot implements IBoot {
|
||||
}
|
||||
}
|
||||
|
||||
public async connectRedis(app: Application) {
|
||||
const { url, pw } = app.config.redis
|
||||
if (url) {
|
||||
const redisClient = connectRedis(url, pw);
|
||||
app.context.redisClient = redisClient;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user