forked from JeniTurtle/egg-nacos-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
33 lines (26 loc) · 771 Bytes
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Application, IBoot } from 'egg';
import NacosClient from './lib/nacosClient';
import NacosConfig from './lib/nacosConfig';
export default class AppBoot implements IBoot {
constructor(private app: Application) {}
configWillLoad() {}
async didLoad() {
if (this.app.config.nacos?.serverList) {
this.app.nacosNaming = new NacosClient(this.app);
}
if (this.app.config.nacos?.configCenter) {
this.app.nacosConfig = new NacosConfig(this.app);
await this.app.nacosConfig.createClient();
// @ts-ignore
process.on('SIGINT', () => {
this.beforeClose();
});
}
}
async willReady() {}
async didReady() {}
async serverDidReady() {}
async beforeClose() {
this.app.nacosConfig.close();
}
}