ee-core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cross/crossProcess.js +10 -5
- package/jobs/child/app.js +9 -4
- package/package.json +2 -1
package/cross/crossProcess.js
CHANGED
|
@@ -10,6 +10,7 @@ const { getRandomString, getValueFromArgv } = require('../utils/helper');
|
|
|
10
10
|
const { is } = require('../utils');
|
|
11
11
|
const { parseArgv } = require('../utils/pargv');
|
|
12
12
|
const { app: electronApp } = require('electron');
|
|
13
|
+
const tkill = require('tree-kill');
|
|
13
14
|
|
|
14
15
|
class CrossProcess {
|
|
15
16
|
constructor(host, opt = {}) {
|
|
@@ -116,11 +117,15 @@ class CrossProcess {
|
|
|
116
117
|
* kill
|
|
117
118
|
*/
|
|
118
119
|
kill(timeout = 1000) {
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
tkill(this.pid, 'SIGINT', (err) => {
|
|
121
|
+
if (err) {
|
|
122
|
+
coreLogger.error(`[ee-core] [corss/process] kill cross-process, error: ${err}, pid:${this.pid}`);
|
|
123
|
+
tkill(this.pid, 'SIGKILL');
|
|
124
|
+
}
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
this._exitElectron();
|
|
127
|
+
}, timeout)
|
|
128
|
+
})
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
getUrl() {
|
package/jobs/child/app.js
CHANGED
|
@@ -47,15 +47,20 @@ class ChildApp {
|
|
|
47
47
|
const {jobPath, jobParams, jobFunc, jobFuncParams} = msg;
|
|
48
48
|
let mod = requireFile(jobPath);
|
|
49
49
|
if (is.class(mod) || isBytecodeClass(mod)) {
|
|
50
|
+
let instance;
|
|
50
51
|
if (!this.jobMap.has(jobPath)) {
|
|
51
|
-
|
|
52
|
-
instance.handle(...jobParams);
|
|
52
|
+
instance = new mod(...jobParams);
|
|
53
53
|
this.jobMap.set(jobPath, instance);
|
|
54
54
|
} else {
|
|
55
|
-
|
|
56
|
-
instance[jobFunc](...jobFuncParams);
|
|
55
|
+
instance = this.jobMap.get(jobPath);
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
// 如果指定了函数名,则调用指定的函数
|
|
59
|
+
if (jobFunc) {
|
|
60
|
+
instance[jobFunc](...jobFuncParams);
|
|
61
|
+
} else {
|
|
62
|
+
instance.handle(...jobParams);
|
|
63
|
+
}
|
|
59
64
|
} else if (is.function(mod)) {
|
|
60
65
|
mod(jobParams);
|
|
61
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"serialize-javascript": "^6.0.1",
|
|
34
34
|
"socket.io": "^4.6.1",
|
|
35
35
|
"socket.io-client": "^4.6.1",
|
|
36
|
+
"tree-kill": "^1.2.2",
|
|
36
37
|
"urllib": "^2.38.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|