This repository was archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathapp.ts
More file actions
57 lines (47 loc) · 1.25 KB
/
Copy pathapp.ts
File metadata and controls
57 lines (47 loc) · 1.25 KB
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
48
49
50
51
52
53
54
55
56
57
/**
* Application
*/
import { Application, IBoot, Context } from 'egg';
import * as moment from 'moment';
export default class AdminBoot implements IBoot {
// private readonly app: Application;
private readonly ctx: Context;
constructor(app: Application) {
// this.app = app;
this.ctx = app.createAnonymousContext();
// agent send
app.messenger.on('init-task', () => {
// 启动任务
this.ctx.service.admin.sys.task.initTask();
});
// Date time
// eslint-disable-next-line no-extend-native
Date.prototype.toJSON = function() {
return moment(this).format('YYYY-MM-DD HH:mm:ss');
};
}
configWillLoad() {
// Ready to call configDidLoad,
// Config, plugin files are referred,
// this is the last chance to modify the config.
}
configDidLoad() {
// Config, plugin files have loaded.
}
async didLoad() {
// All files have loaded, start plugin here.
}
async willReady() {
// All plugins have started, can do some thing before app ready.
}
async didReady() {
// Worker is ready, can do some things
// don't need to block the app boot.
}
async serverDidReady() {
// Server is listening.
}
async beforeClose() {
// Do some thing before app close.
}
}