-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (32 loc) · 791 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
'use strict';
const Queue = require('bull');
class AppBootHook {
constructor(app) {
this.app = app;
}
configWillLoad() {
}
async didLoad() {
// 开启队列
this.app.queue = new Queue(this.app.config.queue.msgcenter, {
redis: this.app.config.redis.client,
limiter: {
max: 1000,
duration: 5000,
},
});
const ctx = await this.app.createAnonymousContext();
this.app.queue.process(function(job, done) {
return ctx.service.getui.sendByCode(job.data.data).then(() => done());
});
}
async willReady() {
// TODO
}
async didReady() {
// 应用已经启动完毕
// const ctx = await this.app.createAnonymousContext();
// await ctx.service.Biz.request();
}
}
module.exports = AppBootHook;