forked from jianghujs/jianghu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (36 loc) · 903 Bytes
/
app.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
const { createJianghuKnex } = require('./app/common/jianghuKnexUtil');
/**
* 配置文件即将加载,这是最后动态修改配置的时机(configWillLoad)
* 配置文件加载完成(configDidLoad)
* 文件加载完成(didLoad)
* 插件启动完毕(willReady)
* worker 准备就绪(didReady)
* 应用启动完成(serverDidReady)
* 应用即将关闭(beforeClose)
*/
class AppBootHook {
constructor(app) {
this.app = app;
}
configWillLoad() {
}
configDidLoad() {
// 挂载jianghuKnex
this.app.jianghuKnex = createJianghuKnex(this.app.knex);
}
async didLoad() {
}
async willReady() {
if (this.app.config.jianghuConfig.enableSocket) {
await this.app.socketIOInit(this.app);
}
}
async didReady() {
}
async serverDidReady() {
}
async beforeClose() {
}
}
module.exports = AppBootHook;