ee-core 2.10.1 → 2.11.0-beta.1
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/addon/window/index.js +3 -3
- package/controller/baseContextClass.js +8 -17
- package/controller/index.js +8 -17
- package/cross/spawnProcess.js +2 -1
- package/jobs/child/app.js +13 -7
- package/jobs/child/forkProcess.js +20 -1
- package/log/logger.js +19 -3
- package/message/childMessage.js +2 -2
- package/package.json +1 -1
- package/services/baseContextClass.js +8 -18
package/addon/window/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { BrowserWindow } = require('electron');
|
|
2
|
+
const extend = require('../../utils/extend');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 窗口插件
|
|
@@ -23,9 +24,8 @@ class WinAddon {
|
|
|
23
24
|
// if (this.windowContentsIdMap.hasOwnProperty(name)) {
|
|
24
25
|
// throw new Error(`[addon] [window] Name: ${name} already exists!`);
|
|
25
26
|
// }
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const options = Object.assign({
|
|
27
|
+
|
|
28
|
+
const options = extend(true, {}, {
|
|
29
29
|
x: 10,
|
|
30
30
|
y: 10,
|
|
31
31
|
width: 980,
|
|
@@ -3,31 +3,22 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* BaseContextClass is a base class that can be extended,
|
|
5
5
|
* it's instantiated in context level,
|
|
6
|
-
* {@link Helper}, {@link Service} is extending it.
|
|
7
6
|
*/
|
|
8
7
|
class BaseContextClass {
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @class
|
|
12
11
|
* @param {Context} ctx - context instance
|
|
13
|
-
* @since 1.
|
|
12
|
+
* @since 1.1.0
|
|
14
13
|
*/
|
|
15
14
|
constructor(ctx) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @since 1.0.0
|
|
24
|
-
*/
|
|
25
|
-
this.config = ctx.config;
|
|
26
|
-
/**
|
|
27
|
-
* @member {Service} BaseContextClass#service
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
this.service = ctx.service;
|
|
15
|
+
|
|
16
|
+
// todo 兼容旧版本,后续废弃ctx
|
|
17
|
+
if (typeof ctx === 'object') {
|
|
18
|
+
this.app = ctx;
|
|
19
|
+
this.config = ctx.config;
|
|
20
|
+
this.service = ctx.service;
|
|
21
|
+
}
|
|
31
22
|
}
|
|
32
23
|
}
|
|
33
24
|
|
package/controller/index.js
CHANGED
|
@@ -3,31 +3,22 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* BaseContextClass is a base class that can be extended,
|
|
5
5
|
* it's instantiated in context level,
|
|
6
|
-
* {@link Helper}, {@link Service} is extending it.
|
|
7
6
|
*/
|
|
8
7
|
class BaseContextClass {
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @class
|
|
12
11
|
* @param {Context} ctx - context instance
|
|
13
|
-
* @since 1.
|
|
12
|
+
* @since 1.1.0
|
|
14
13
|
*/
|
|
15
14
|
constructor(ctx) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @since 1.0.0
|
|
24
|
-
*/
|
|
25
|
-
this.config = ctx.config;
|
|
26
|
-
/**
|
|
27
|
-
* @member {Service} BaseContextClass#service
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
this.service = ctx.service;
|
|
15
|
+
|
|
16
|
+
// todo 兼容旧版本,后续废弃ctx
|
|
17
|
+
if (typeof ctx === 'object') {
|
|
18
|
+
this.app = ctx;
|
|
19
|
+
this.config = ctx.config;
|
|
20
|
+
this.service = ctx.service;
|
|
21
|
+
}
|
|
31
22
|
}
|
|
32
23
|
}
|
|
33
24
|
|
package/cross/spawnProcess.js
CHANGED
|
@@ -95,7 +95,8 @@ class SpawnProcess {
|
|
|
95
95
|
pid: this.pid
|
|
96
96
|
}
|
|
97
97
|
this.host.emitter.emit(Channel.events.childProcessExit, data);
|
|
98
|
-
|
|
98
|
+
// Child process closed: The child process was killed externally or an internal error caused the application to stop, resulting in the application exiting
|
|
99
|
+
Log.coreLogger.info(`[ee-core] [corss/process] received a exit from child-process, code:${code}, signal:${signal}, pid:${this.pid}, cmd:${cmdPath}, args: ${cmdArgs}`);
|
|
99
100
|
this._exitElectron();
|
|
100
101
|
});
|
|
101
102
|
|
package/jobs/child/app.js
CHANGED
|
@@ -11,6 +11,7 @@ const commands = ['run'];
|
|
|
11
11
|
class ChildApp {
|
|
12
12
|
constructor() {
|
|
13
13
|
this._initEvents();
|
|
14
|
+
this.jobMap = new Map();
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -43,15 +44,20 @@ class ChildApp {
|
|
|
43
44
|
* 运行脚本
|
|
44
45
|
*/
|
|
45
46
|
run(msg = {}) {
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
let mod = Loader.loadJsFile(filepath);
|
|
47
|
+
const {jobPath, jobParams, jobFunc, jobFuncParams} = msg;
|
|
48
|
+
let mod = Loader.loadJsFile(jobPath);
|
|
50
49
|
if (is.class(mod) || UtilsCore.isBytecodeClass(mod)) {
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (!this.jobMap.has(jobPath)) {
|
|
51
|
+
const instance = new mod(...jobParams);
|
|
52
|
+
instance.handle(...jobParams);
|
|
53
|
+
this.jobMap.set(jobPath, instance);
|
|
54
|
+
} else {
|
|
55
|
+
const instance = this.jobMap.get(jobPath);
|
|
56
|
+
instance[jobFunc](...jobFuncParams);
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
} else if (is.function(mod)) {
|
|
54
|
-
mod(
|
|
60
|
+
mod(jobParams);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -6,6 +6,7 @@ const Log = require('../../log');
|
|
|
6
6
|
const Ps = require('../../ps');
|
|
7
7
|
const Channel = require('../../const/channel');
|
|
8
8
|
const Helper = require('../../utils/helper');
|
|
9
|
+
const Loader = require('../../loader');
|
|
9
10
|
|
|
10
11
|
class ForkProcess {
|
|
11
12
|
constructor(host, opt = {}) {
|
|
@@ -98,7 +99,7 @@ class ForkProcess {
|
|
|
98
99
|
/**
|
|
99
100
|
* 分发任务
|
|
100
101
|
*/
|
|
101
|
-
dispatch(cmd, jobPath = '', params
|
|
102
|
+
dispatch(cmd, jobPath = '', ...params) {
|
|
102
103
|
// 消息对象
|
|
103
104
|
const mid = Helper.getRandomString();
|
|
104
105
|
let msg = {
|
|
@@ -113,6 +114,24 @@ class ForkProcess {
|
|
|
113
114
|
this.child.send(msg);
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
/**
|
|
118
|
+
* 调用job的方法
|
|
119
|
+
*/
|
|
120
|
+
callFunc(jobPath = '', funcName = '', ...params) {
|
|
121
|
+
jobPath = Loader.getFullpath(jobPath);
|
|
122
|
+
|
|
123
|
+
// 消息对象
|
|
124
|
+
const mid = Helper.getRandomString();
|
|
125
|
+
let msg = {
|
|
126
|
+
mid,
|
|
127
|
+
cmd:'run',
|
|
128
|
+
jobPath,
|
|
129
|
+
jobFunc: funcName,
|
|
130
|
+
jobFuncParams: params
|
|
131
|
+
}
|
|
132
|
+
this.child.send(msg);
|
|
133
|
+
}
|
|
134
|
+
|
|
116
135
|
/**
|
|
117
136
|
* kill
|
|
118
137
|
*/
|
package/log/logger.js
CHANGED
|
@@ -6,6 +6,11 @@ const Ps = require('../ps');
|
|
|
6
6
|
const Conf = require('../config');
|
|
7
7
|
const ConfigCache = require('../config/cache');
|
|
8
8
|
let LogDate = 0;
|
|
9
|
+
const TmpFileName = {
|
|
10
|
+
appLogName: '',
|
|
11
|
+
coreLogName: '',
|
|
12
|
+
errorLogName: '',
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
module.exports = {
|
|
11
16
|
|
|
@@ -73,9 +78,20 @@ module.exports = {
|
|
|
73
78
|
let now = parseInt(dayjs().format('YYYYMMDD'));
|
|
74
79
|
if (LogDate != now) {
|
|
75
80
|
LogDate = now;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
|
|
82
|
+
// 保存一个临时文件名,防止文件名按日期累加
|
|
83
|
+
if (TmpFileName.appLogName.length == 0) {
|
|
84
|
+
TmpFileName.appLogName = logOpt.logger.appLogName;
|
|
85
|
+
}
|
|
86
|
+
if (TmpFileName.coreLogName.length == 0) {
|
|
87
|
+
TmpFileName.coreLogName = logOpt.logger.coreLogName;
|
|
88
|
+
}
|
|
89
|
+
if (TmpFileName.errorLogName.length == 0) {
|
|
90
|
+
TmpFileName.errorLogName = logOpt.logger.errorLogName;
|
|
91
|
+
}
|
|
92
|
+
let appLogName = TmpFileName.appLogName;
|
|
93
|
+
let coreLogName = TmpFileName.coreLogName;
|
|
94
|
+
let errorLogName = TmpFileName.errorLogName;
|
|
79
95
|
let appLogExtname = path.extname(appLogName);
|
|
80
96
|
let coreLogExtname = path.extname(coreLogName);
|
|
81
97
|
let errorLogExtname = path.extname(errorLogName);
|
package/message/childMessage.js
CHANGED
|
@@ -6,7 +6,7 @@ class ChildMessage {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* 向主进程发消息
|
|
9
|
+
* 向主进程发消息 for ChildJob 实例
|
|
10
10
|
*/
|
|
11
11
|
sendToMain(eventName, params = {}) {
|
|
12
12
|
let receiver = Channel.receiver.childJob;
|
|
@@ -14,7 +14,7 @@ class ChildMessage {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* 向主进程发消息
|
|
17
|
+
* 向主进程发消息 for task 实例
|
|
18
18
|
*/
|
|
19
19
|
send(eventName, params = {}, receiver) {
|
|
20
20
|
let eventReceiver = receiver || Channel.receiver.forkProcess;
|
package/package.json
CHANGED
|
@@ -2,32 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* BaseContextClass is a base class that can be extended,
|
|
5
|
-
* it's instantiated in context level,
|
|
6
|
-
* {@link Helper}, {@link Service} is extending it.
|
|
7
5
|
*/
|
|
8
6
|
class BaseContextClass {
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* @class
|
|
12
10
|
* @param {Context} ctx - context instance
|
|
13
|
-
* @since 1.
|
|
11
|
+
* @since 1.1.0
|
|
14
12
|
*/
|
|
15
13
|
constructor(ctx) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @since 1.0.0
|
|
24
|
-
*/
|
|
25
|
-
this.config = ctx.config;
|
|
26
|
-
/**
|
|
27
|
-
* @member {Service} BaseContextClass#service
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
this.service = ctx.service;
|
|
14
|
+
|
|
15
|
+
// todo 兼容旧版本,后续废弃ctx
|
|
16
|
+
if (typeof ctx === 'object') {
|
|
17
|
+
this.app = ctx;
|
|
18
|
+
this.config = ctx.config;
|
|
19
|
+
this.service = ctx.service;
|
|
20
|
+
}
|
|
31
21
|
}
|
|
32
22
|
}
|
|
33
23
|
|