Skip to content

Commit

Permalink
fix: remove loader.loadBootHook
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored and fengmk2 committed Sep 22, 2018
1 parent 6a7db2a commit bace243
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
13 changes: 7 additions & 6 deletions docs/assets/lifecycle_cn.puml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ partition agent {
====
方法模式
beforeStart(deprecate)
end note
end note
fork
: configDidLoad;
note left
文件都已经加载完成,
可以执行一些同步逻辑
与 agent.js 里的同步逻辑相同,执行顺序也相同
可以执行一些同步逻辑。
end note
: async didLoad;
note left
Expand All @@ -34,7 +35,7 @@ partition agent {
note right
beforeStart注册的任务
在此时同时并行执行
end note
end note
endfork
: async willReady;
note left
Expand All @@ -49,7 +50,7 @@ partition agent {
可以正常工作
====
时间点与原来的ready相同,
原来的ready不支持AsyncFunction
原来的ready不支持AsyncFunction
end note
: emit 'agent-start';
}
Expand All @@ -72,7 +73,7 @@ partition app {
: configDidLoad;
note left
文件都已经加载完成,
与 app.js 里的同步逻辑相同,
与 app.js 里的同步逻辑相同,执行顺序也相同
可以修改一些配置, 修改中间件的顺序
end note
: load app/service;
Expand Down Expand Up @@ -128,4 +129,4 @@ note right
end note
endfork
stop
@enduml
@enduml
9 changes: 5 additions & 4 deletions docs/assets/lifecycle_en.puml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ partition agent {
====
method mode
beforeStart(deprecate)
end note
end note
fork
: configDidLoad;
note left
Expand All @@ -25,6 +25,7 @@ partition agent {
: async didLoad;
note left
Files and configs are loaded
The same sync logic and execution sequence as in app.js,
To execute some async tasks
E.g: Pull configs in async to load client,
or check the state of client
Expand All @@ -34,7 +35,7 @@ partition agent {
note right
Tasks mounted on beforeStart
Running in parallel at this time
end note
end note
endfork
: async willReady;
note left
Expand All @@ -49,7 +50,7 @@ partition agent {
and it can work normally
====
The time is the same as 'ready',
The original 'ready' doesn't support AsyncFunction
The original 'ready' doesn't support AsyncFunction
end note
: emit 'agent-start';
}
Expand All @@ -72,7 +73,7 @@ partition app {
: configDidLoad;
note left
All the files are loaded,
The same sync logic as in app.js,
The same sync logic and execution sequence as in app.js,
Some configs can be modified, the order of middlewares
end note
: load app/service;
Expand Down
5 changes: 2 additions & 3 deletions docs/source/en/advanced/loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ module.exports = AppBootHook;
The framework will automatically load and initialize this class after developers have defined `app.js` and `agenet.js` in the form of class, and it will call the corresponding methods during each of the life cycles.

Here's the image of starting process:

![]( https://user-images.githubusercontent.com/6897780/45463932-bb1f9800-b740-11e8-9f0c-d9649ae8abc0.png)
![](https://cdn.nlark.com/__puml/da20f7e73aef1984354619fefcfc7ced.svg)

**Notice: We have an expiring time limitation when using `beforeClose` to close the processing of the framework. If a worker has accepted the signal of exit but doesn't exit within the limit period, it will be FORCELY closed.**

Expand Down Expand Up @@ -478,7 +477,7 @@ app/service | false

#### call [Boolean]

Calling when export's object is function, and get the return value, the default is true
Calling when export's object is function, and get the return value, the default is true

Loading different files uses different configurations:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh-cn/advanced/loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ module.exports = AppBootHook;

启动过程如图所示:

![](https://user-images.githubusercontent.com/6897780/42219323-24cbd7a8-7efe-11e8-86b9-cf280846aa9f.png)
![](https://cdn.nlark.com/__puml/da20f7e73aef1984354619fefcfc7ced.svg)

**使用 `beforeClose` 的时候需要注意,在框架的进程关闭处理中是有超时时间的,如果 worker 进程在接收到进程退出信号之后,没有在所规定的时间内退出,将会被强制关闭。**

Expand Down
1 change: 0 additions & 1 deletion lib/loader/agent_worker_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AgentWorkerLoader extends EggLoader {

load() {
this.loadAgentExtend();
this.loadBootHook();
this.loadCustomAgent();
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/loader/app_worker_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class AppWorkerLoader extends EggLoader {
this.loadHelperExtend();

// app > plugin
this.loadBootHook();
this.loadCustomApp();
// app > plugin
this.loadService();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"delegates": "^1.0.0",
"egg-cluster": "^1.19.1",
"egg-cookies": "^2.2.6",
"egg-core": "^4.10.0",
"egg-core": "^4.10.2",
"egg-development": "^2.4.1",
"egg-i18n": "^2.0.0",
"egg-jsonp": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ describe('test/lib/egg.test.js', () => {

it('should read timing data', function* () {
let json = readJson(path.join(baseDir, `run/agent_timing_${process.pid}.json`));
assert(json.length === 38);
assert(json.length === 32);
assert(json[0].name === 'Application Start');
assert(json[0].pid === process.pid);

json = readJson(path.join(baseDir, `run/application_timing_${process.pid}.json`));
assert(json.length === 74);
assert(json.length === 62);
assert(json[0].name === 'Application Start');
assert(json[0].pid === process.pid);
});
Expand Down

0 comments on commit bace243

Please sign in to comment.