ee-core 2.0.0-beta.3 → 2.0.0-beta.4
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/index.js +12 -13
- package/{lib → module/app}/application.js +2 -2
- package/{lib → module/app}/baseApp.js +3 -3
- package/{lib → module/app}/eeApp.js +2 -2
- package/module/app/index.js +5 -0
- package/{config → module/config}/config.default.js +2 -3
- package/module/const/channel.js +6 -0
- package/{core → module/core}/index.js +0 -2
- package/{core → module/core}/lib/ee.js +0 -2
- package/{core → module/core}/lib/loader/ee_loader.js +1 -1
- package/{core → module/core}/lib/loader/mixin/addon.js +1 -1
- package/module/core/lib/utils/base_context_class.js +34 -0
- package/module/exception/index.js +75 -6
- package/module/httpclient/index.js +2 -2
- package/module/jobs/baseJobClass.js +16 -0
- package/module/jobs/child/app.js +38 -18
- package/module/jobs/child/forkProcess.js +17 -38
- package/module/jobs/child/index.js +37 -20
- package/module/jobs/childPool/app.js +68 -0
- package/module/jobs/childPool/forkProcess.js +81 -0
- package/module/jobs/childPool/index.js +71 -0
- package/module/jobs/{child → childPool}/pool.js +3 -3
- package/module/jobs/renderer/loadView.js +1 -1
- package/module/jobs/unification.js +1 -1
- package/module/loader/index.js +36 -14
- package/module/log/logger.js +1 -1
- package/module/message/childMessage.js +11 -43
- package/module/message/index.js +2 -9
- package/{utils → module/oldUtils}/index.js +6 -6
- package/module/{utils/ps.js → ps/index.js} +20 -0
- package/module/service/index.js +34 -0
- package/module/socket/httpServer.js +1 -1
- package/module/socket/io.js +2 -2
- package/module/socket/ipcServer.js +3 -3
- package/module/socket/socketClient.js +2 -2
- package/module/socket/socketServer.js +3 -3
- package/module/storage/jsondbStorage.js +1 -1
- package/module/storage/sqliteStorage.js +1 -1
- package/{tools → module/tools}/encrypt.js +1 -1
- package/module/utils/helper.js +0 -1
- package/module/utils/index.js +1 -1
- package/package.json +3 -2
- package/module/message/ipcMain.js +0 -160
- package/module/message/ipcRender.js +0 -0
- package/module/message/manager.js +0 -0
- package/module/message/messenger.js +0 -0
- /package/{addon → module/addon}/window/index.js +0 -0
- /package/{lib → module/app}/appLoader.js +0 -0
- /package/{bin → module/bin}/tools.js +0 -0
- /package/{core/lib/utils/base_context_class.js → module/controller/index.js} +0 -0
- /package/{core → module/core}/lib/loader/context_loader.js +0 -0
- /package/{core → module/core}/lib/loader/file_loader.js +0 -0
- /package/{core → module/core}/lib/loader/mixin/config.js +0 -0
- /package/{core → module/core}/lib/loader/mixin/controller.js +0 -0
- /package/{core → module/core}/lib/loader/mixin/service.js +0 -0
- /package/{core → module/core}/lib/utils/function.js +0 -0
- /package/{core → module/core}/lib/utils/index.js +0 -0
- /package/{core → module/core}/lib/utils/sequencify.js +0 -0
- /package/{core → module/core}/lib/utils/timing.js +0 -0
- /package/{tools → module/tools}/replaceDist.js +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { fork } = require('child_process');
|
|
3
|
+
const serialize = require('serialize-javascript');
|
|
4
|
+
const Log = require('../../log');
|
|
5
|
+
const Ps = require('../../ps');
|
|
6
|
+
const Channel = require('../../const/channel');
|
|
7
|
+
|
|
8
|
+
class ForkProcess {
|
|
9
|
+
constructor(host, opt = {}) {
|
|
10
|
+
|
|
11
|
+
let options = Object.assign({
|
|
12
|
+
processOptions: {
|
|
13
|
+
cwd: Ps.getHomeDir(),
|
|
14
|
+
env: Ps.allEnv(),
|
|
15
|
+
stdio: 'pipe'
|
|
16
|
+
}
|
|
17
|
+
}, opt);
|
|
18
|
+
|
|
19
|
+
this.host = host;
|
|
20
|
+
this.args = [];
|
|
21
|
+
this.sleeping = false;
|
|
22
|
+
|
|
23
|
+
// 传递给子进程的参数
|
|
24
|
+
//this.args.push(JSON.stringify(options.params));
|
|
25
|
+
|
|
26
|
+
const appPath = path.join(__dirname, 'app.js');
|
|
27
|
+
this.child = fork(appPath, this.args, options.processOptions);
|
|
28
|
+
|
|
29
|
+
this.pid = this.child.pid;
|
|
30
|
+
this._init();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 进程初始化
|
|
35
|
+
*/
|
|
36
|
+
_init() {
|
|
37
|
+
this.child.on('message', (m) => {
|
|
38
|
+
Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-message: ${serialize(m)}`);
|
|
39
|
+
if (m.channel == Channel.process.showException) {
|
|
40
|
+
Log.coreLogger.error(`${m.data}`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.child.on('disconnect', () => {
|
|
45
|
+
Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-disconnect !`);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.child.on('close', (code, signal) => {
|
|
49
|
+
Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-close code:${code}, signal:${signal}`);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.child.on('exit', (code, signal) => {
|
|
53
|
+
Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-exit code:${code}, signal:${signal}`);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.child.on('error', (err) => {
|
|
57
|
+
Log.coreLogger.error(`[ee-core] [jobs/child/forkProcess] from childProcess event-error: ${err} !`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 进程挂起
|
|
63
|
+
*/
|
|
64
|
+
sleep() {
|
|
65
|
+
if (this.sleeping) return;
|
|
66
|
+
process.kill(this.pid, 'SIGSTOP');
|
|
67
|
+
this.sleeping = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 进程唤醒
|
|
72
|
+
*/
|
|
73
|
+
wakeup() {
|
|
74
|
+
if (!this.sleeping) return;
|
|
75
|
+
process.kill(this.pid, 'SIGCONT');
|
|
76
|
+
this.sleeping = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = ForkProcess;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const EventEmitter = require('events');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const ForkProcess = require('./forkProcess');
|
|
5
|
+
const Ps = require('../../ps');
|
|
6
|
+
const Loader = require('../../loader');
|
|
7
|
+
const Helper = require('../../utils/helper');
|
|
8
|
+
|
|
9
|
+
class ChildJob extends EventEmitter {
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.jobList = new Map();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 执行一个job文件
|
|
18
|
+
*/
|
|
19
|
+
exec(filepath, opt = {}) {
|
|
20
|
+
const jobPath = this._getFullpath(filepath);
|
|
21
|
+
let options = Object.assign({
|
|
22
|
+
params: {},
|
|
23
|
+
}, opt);
|
|
24
|
+
|
|
25
|
+
// 消息对象
|
|
26
|
+
const mid = Helper.getRandomString();
|
|
27
|
+
let msg = {
|
|
28
|
+
mid,
|
|
29
|
+
jobPath,
|
|
30
|
+
params: options.params
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let subProcess = new ForkProcess(this, options);
|
|
34
|
+
|
|
35
|
+
// todo 是否会发生监听未完成时,接收不到消息?
|
|
36
|
+
// 发消息到子进程,
|
|
37
|
+
subProcess.child.send(msg);
|
|
38
|
+
|
|
39
|
+
return subProcess;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* todo 运行job
|
|
44
|
+
*/
|
|
45
|
+
run(name, filepath, opt = {}) {
|
|
46
|
+
let times = opt.times || 1;
|
|
47
|
+
|
|
48
|
+
for (let i = 1; i <= times; i++) {
|
|
49
|
+
this.exec(filepath, opt);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_getFullpath(filepath) {
|
|
56
|
+
const isAbsolute = path.isAbsolute(filepath);
|
|
57
|
+
if (!isAbsolute) {
|
|
58
|
+
filepath = path.join(Ps.getBaseDir(), filepath);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const fullpath = Loader.resolveModule(filepath);
|
|
62
|
+
if (!fs.existsSync(fullpath)) {
|
|
63
|
+
throw new Error(`[ee-core] [jobs/child] file ${fullpath} not exists`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return fullpath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = ChildJob;
|
|
@@ -2,7 +2,7 @@ const EventEmitter = require('events');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const ForkProcess = require('./forkProcess');
|
|
5
|
-
const Ps = require('../../
|
|
5
|
+
const Ps = require('../../ps');
|
|
6
6
|
const Loader = require('../../loader');
|
|
7
7
|
const Log = require('../../log');
|
|
8
8
|
|
|
@@ -30,7 +30,7 @@ class ChildJob {
|
|
|
30
30
|
|
|
31
31
|
const fullpath = Loader.resolveModule(filepath);
|
|
32
32
|
if (!fs.existsSync(fullpath)) {
|
|
33
|
-
throw new Error(`[ee-core] [
|
|
33
|
+
throw new Error(`[ee-core] [jobs/child] file ${fullpath} not exists`);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
let options = Object.assign({
|
|
@@ -54,7 +54,7 @@ class ChildJob {
|
|
|
54
54
|
|
|
55
55
|
sendToChild(pid, message, ...other) {
|
|
56
56
|
if (!this.pools.has(pid)) {
|
|
57
|
-
Log.coreLogger.warn(`[ee-core] [
|
|
57
|
+
Log.coreLogger.warn(`[ee-core] [jobs/child] process dose not exist ${pid}`);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
const subProcess = this.pools.get(pid);
|
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const RendererJob = require('./renderer');
|
|
4
4
|
const ChildJob = require('./child/pool');
|
|
5
|
-
const Ps = require('../
|
|
5
|
+
const Ps = require('../ps');
|
|
6
6
|
const Loader = require('../loader');
|
|
7
7
|
|
|
8
8
|
class Jobs {
|
package/module/loader/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const is = require('is-type-of');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const UtilsCore = require('
|
|
5
|
-
const Ps = require('../
|
|
4
|
+
const UtilsCore = require('../core/lib/utils');
|
|
5
|
+
const Ps = require('../ps');
|
|
6
6
|
const Log = require('../log');
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
|
23
23
|
|
|
24
24
|
filepath = filepath && this.resolveModule(filepath);
|
|
25
25
|
if (!fs.existsSync(filepath)) {
|
|
26
|
-
let errorMsg = `[ee-core] [
|
|
26
|
+
let errorMsg = `[ee-core] [loader/index] loadOneFile ${filepath} does not exist`;
|
|
27
27
|
Log.coreLogger.error(errorMsg);
|
|
28
28
|
throw new Error(errorMsg);
|
|
29
29
|
}
|
|
@@ -36,26 +36,48 @@ module.exports = {
|
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* 加载
|
|
39
|
+
* 加载js文件
|
|
40
40
|
*
|
|
41
41
|
* @param {String} filepath - fullpath
|
|
42
|
-
* @
|
|
43
|
-
* @return {Object} exports
|
|
42
|
+
* @return {Any} exports
|
|
44
43
|
* @since 1.0.0
|
|
45
44
|
*/
|
|
46
|
-
|
|
45
|
+
loadJsFile (filepath) {
|
|
47
46
|
if (!fs.existsSync(filepath)) {
|
|
48
|
-
let
|
|
49
|
-
Log.coreLogger.error(
|
|
47
|
+
let errMsg = `[ee-core] [loader] loadJobFile ${filepath} does not exist`;
|
|
48
|
+
Log.coreLogger.error(errMsg);
|
|
49
|
+
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const ret = UtilsCore.loadFile(filepath);
|
|
53
|
-
if (is.function(ret) && !is.class(ret) && !UtilsCore.isBytecodeClass(ret)) {
|
|
54
|
-
ret = ret(...inject);
|
|
55
|
-
}
|
|
56
53
|
return ret;
|
|
57
54
|
},
|
|
58
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 加载并运行js文件
|
|
58
|
+
*
|
|
59
|
+
* @param {String} filepath - fullpath
|
|
60
|
+
* @param {Array} inject - pass rest arguments into the function when invoke
|
|
61
|
+
* @return {Any}
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
execJsFile (filepath, ...inject) {
|
|
65
|
+
if (!fs.existsSync(filepath)) {
|
|
66
|
+
let errMsg = `[ee-core] [loader] loadJobFile ${filepath} does not exist`;
|
|
67
|
+
Log.coreLogger.error(errMsg);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let ret = UtilsCore.loadFile(filepath);
|
|
72
|
+
if (is.class(ret) || UtilsCore.isBytecodeClass(ret)) {
|
|
73
|
+
ret = new ret(inject);
|
|
74
|
+
} else if (is.function(ret)) {
|
|
75
|
+
ret = ret(inject);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ret;
|
|
79
|
+
},
|
|
80
|
+
|
|
59
81
|
/**
|
|
60
82
|
* 模块的绝对路径
|
|
61
83
|
* @param {String} filepath - fullpath
|
|
@@ -75,7 +97,7 @@ module.exports = {
|
|
|
75
97
|
|
|
76
98
|
if (!fs.existsSync(filepath) && !fs.existsSync(fullpath)) {
|
|
77
99
|
let files = { filepath, fullpath }
|
|
78
|
-
Log.coreLogger.warn(`[ee-core] [
|
|
100
|
+
Log.coreLogger.warn(`[ee-core] [loader] resolveModule unknow filepath: ${files}`)
|
|
79
101
|
return undefined;
|
|
80
102
|
}
|
|
81
103
|
}
|
|
@@ -99,7 +121,7 @@ module.exports = {
|
|
|
99
121
|
|
|
100
122
|
fullpath = this.resolveModule(filepath);
|
|
101
123
|
if (!fs.existsSync(fullpath)) {
|
|
102
|
-
let errorMsg = `[ee-core] [
|
|
124
|
+
let errorMsg = `[ee-core] [loader] requireModule filepath: ${filepath} does not exist`;
|
|
103
125
|
Log.coreLogger.error(errorMsg);
|
|
104
126
|
}
|
|
105
127
|
const ret = UtilsCore.loadFile(fullpath);
|
package/module/log/logger.js
CHANGED
|
@@ -1,60 +1,28 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Channel = require('../const/channel');
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* ChildMessage
|
|
5
|
-
*/
|
|
6
3
|
class ChildMessage {
|
|
7
4
|
constructor() {
|
|
8
5
|
// ...
|
|
9
6
|
}
|
|
10
7
|
|
|
11
|
-
/**
|
|
12
|
-
* 初始化事件监听
|
|
13
|
-
*/
|
|
14
|
-
initEvents() {
|
|
15
|
-
process.on('disconnect', () => {
|
|
16
|
-
Log.coreLogger.info(`[ee-core] [module/message/childMessage] child process disconnected:${process.pid} !`);
|
|
17
|
-
});
|
|
18
|
-
process.on('exit', () => {
|
|
19
|
-
Log.coreLogger.info(`[ee-core] [module/message/childMessage] child process exited:${process.pid} !`);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 监听消息
|
|
25
|
-
*/
|
|
26
|
-
onMessage(handle) {
|
|
27
|
-
Log.coreLogger.info(`[ee-core] [module/message/childMessage] Received a message ${params} from the mainProcess`);
|
|
28
|
-
|
|
29
|
-
process.on('message', handle.bind(this));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 消息处理
|
|
34
|
-
*/
|
|
35
|
-
// _handleMessage(params = {}) {
|
|
36
|
-
// Log.coreLogger.info(`[ee-core] [module/message/childMessage] Received a message ${params} from the mainProcess`);
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
8
|
/**
|
|
40
9
|
* 向主进程发消息
|
|
41
10
|
*/
|
|
42
|
-
sendToMain(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
process.disconnect();
|
|
11
|
+
sendToMain(eventName, params = {}) {
|
|
12
|
+
let message = {
|
|
13
|
+
channel: Channel.process.sendToMain,
|
|
14
|
+
event: eventName,
|
|
15
|
+
data: params,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return process.send(message);
|
|
51
19
|
}
|
|
52
20
|
|
|
53
21
|
/**
|
|
54
22
|
* 进程退出
|
|
55
23
|
*/
|
|
56
|
-
exit() {
|
|
57
|
-
process.exit();
|
|
24
|
+
exit(code = 0) {
|
|
25
|
+
return process.exit(code);
|
|
58
26
|
}
|
|
59
27
|
}
|
|
60
28
|
|
package/module/message/index.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ChildMessage = require('./childMessage');
|
|
2
2
|
const EEChildMessage = Symbol('EeCore#Module#ChildMessage');
|
|
3
3
|
|
|
4
4
|
const message = {
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
create () {
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
|
|
13
6
|
/**
|
|
14
7
|
* childMessage
|
|
15
8
|
*/
|
|
16
9
|
get childMessage() {
|
|
17
10
|
if (!this[EEChildMessage]) {
|
|
18
|
-
this[EEChildMessage] =
|
|
11
|
+
this[EEChildMessage] = new ChildMessage();
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
return this[EEChildMessage] || null;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const UtilsJson = require('../
|
|
7
|
-
const UtilsPs = require('../
|
|
8
|
-
const UtilsHelper = require('../
|
|
9
|
-
const Copy = require('../
|
|
10
|
-
const Storage = require('../
|
|
11
|
-
const Constants = require('../
|
|
6
|
+
const UtilsJson = require('../utils/json');
|
|
7
|
+
const UtilsPs = require('../ps');
|
|
8
|
+
const UtilsHelper = require('../utils/helper');
|
|
9
|
+
const Copy = require('../utils/copyto');
|
|
10
|
+
const Storage = require('../storage');
|
|
11
|
+
const Constants = require('../const');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* other module
|
|
@@ -218,4 +218,24 @@ exports.isEncrypted = function () {
|
|
|
218
218
|
*/
|
|
219
219
|
exports.isHotReload = function () {
|
|
220
220
|
return process.env.HOT_RELOAD === 'true';
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 进程退出
|
|
225
|
+
*/
|
|
226
|
+
exports.exit = function(code = 0) {
|
|
227
|
+
return process.exit(code);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 格式化message
|
|
232
|
+
*/
|
|
233
|
+
exports.makeMessage = function(msg = {}) {
|
|
234
|
+
let message = Object.assign({
|
|
235
|
+
channel: '',
|
|
236
|
+
event: '',
|
|
237
|
+
data: {}
|
|
238
|
+
}, msg);
|
|
239
|
+
|
|
240
|
+
return message;
|
|
221
241
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
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
|
+
*/
|
|
8
|
+
class BaseContextClass {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
* @param {Context} ctx - context instance
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
constructor(ctx) {
|
|
16
|
+
/**
|
|
17
|
+
* @member {Application} BaseContextClass#app
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
this.app = ctx;
|
|
21
|
+
/**
|
|
22
|
+
* @member {Config} BaseContextClass#config
|
|
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;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = BaseContextClass;
|
|
@@ -61,7 +61,7 @@ class HttpServer {
|
|
|
61
61
|
})
|
|
62
62
|
.use(this.dispatch);
|
|
63
63
|
|
|
64
|
-
let msg = '[ee-core] [
|
|
64
|
+
let msg = '[ee-core] [socket/httpServer] server is: ' + url;
|
|
65
65
|
if (isHttps) {
|
|
66
66
|
https.createServer(sslOptions, koaApp.callback()).listen(httpServer.port, (err) => {
|
|
67
67
|
msg = err ? err : msg;
|
package/module/socket/io.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const IoServer = require('socket.io');
|
|
4
4
|
const IoClient = require('socket.io-client');
|
|
5
5
|
//const socketServer = require('./socketServer');
|
|
6
|
-
const socketClient = require('./socketClient');
|
|
6
|
+
// const socketClient = require('./socketClient');
|
|
7
7
|
const Koa = require('koa');
|
|
8
8
|
|
|
9
9
|
const EeSocket = {
|
|
@@ -11,7 +11,7 @@ const EeSocket = {
|
|
|
11
11
|
//return socketServer.getInstance();
|
|
12
12
|
},
|
|
13
13
|
getClient: () => {
|
|
14
|
-
return socketClient.getInstance();
|
|
14
|
+
//return socketClient.getInstance();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -4,7 +4,7 @@ const { ipcMain } = require('electron');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const globby = require('globby');
|
|
7
|
-
const Utils = require('
|
|
7
|
+
const Utils = require('../core/lib/utils');
|
|
8
8
|
const Wrap = require('../utils/wrap');
|
|
9
9
|
const Log = require('../log');
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ class IpcServer {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
register () {
|
|
18
|
-
console.log('[ee-core] [
|
|
18
|
+
console.log('[ee-core] [socket/IpcServer] register channels');
|
|
19
19
|
|
|
20
20
|
const self = this;
|
|
21
21
|
// 遍历方法
|
|
@@ -75,7 +75,7 @@ class IpcServer {
|
|
|
75
75
|
|
|
76
76
|
return fn;
|
|
77
77
|
} catch (err) {
|
|
78
|
-
Log.coreLogger.error('[ee-core] [
|
|
78
|
+
Log.coreLogger.error('[ee-core] [socket/IpcServer] throw error:', err);
|
|
79
79
|
}
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
@@ -11,8 +11,8 @@ class SocketClient {
|
|
|
11
11
|
|
|
12
12
|
assert(typeof port === 'number', 'port required, and must be a number');
|
|
13
13
|
|
|
14
|
-
const url = 'http://
|
|
15
|
-
console.log('[ee-core] [
|
|
14
|
+
const url = 'http://localhost:' + port;
|
|
15
|
+
console.log('[ee-core] [socket/socketClient] url:', url);
|
|
16
16
|
this.client = IoClient(url);
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ class SocketServer {
|
|
|
21
21
|
|
|
22
22
|
let port = process.env.EE_SOCKET_PORT ? parseInt(process.env.EE_SOCKET_PORT) : parseInt(this.getSocketPort());
|
|
23
23
|
assert(typeof port === 'number', 'socekt port required, and must be a number');
|
|
24
|
-
this.consoleLogger.info('[ee-core] [
|
|
24
|
+
this.consoleLogger.info('[ee-core] [socket/socketServer] port is:', port);
|
|
25
25
|
|
|
26
26
|
// let opt = Object.assign({}, options);
|
|
27
27
|
// delete opt.enable;
|
|
@@ -34,7 +34,7 @@ class SocketServer {
|
|
|
34
34
|
this.io.on('connection', (socket) => {
|
|
35
35
|
const channel = Constants.socketIo.channel.partySoftware;
|
|
36
36
|
socket.on(channel, async (message, callback) => {
|
|
37
|
-
console.log('[ee-core] [
|
|
37
|
+
console.log('[ee-core] [socket/socketServer] socket id:' + socket.id + ' message cmd: ' + message.cmd);
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
40
|
// 找函数
|
|
@@ -55,7 +55,7 @@ class SocketServer {
|
|
|
55
55
|
const result = await fn.call(self.app, args);
|
|
56
56
|
callback(result);
|
|
57
57
|
} catch (err) {
|
|
58
|
-
Log.coreLogger.error('[ee-core] [
|
|
58
|
+
Log.coreLogger.error('[ee-core] [socket/socketServer] throw error:', err);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
});
|
|
@@ -6,7 +6,7 @@ const FileSync = require('./jsondb/adapters/FileSync');
|
|
|
6
6
|
const _ = require('lodash');
|
|
7
7
|
const Constants = require('../const');
|
|
8
8
|
const Helper = require('../utils/helper');
|
|
9
|
-
const Ps = require('../
|
|
9
|
+
const Ps = require('../ps');
|
|
10
10
|
|
|
11
11
|
class JsondbStorage {
|
|
12
12
|
constructor (name, opt = {}) {
|
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const Database = require('better-sqlite3');
|
|
7
7
|
const Helper = require('../utils/helper');
|
|
8
|
-
const Ps = require('../
|
|
8
|
+
const Ps = require('../ps');
|
|
9
9
|
|
|
10
10
|
class SqliteStorage {
|
|
11
11
|
constructor (name, opt = {}) {
|
|
@@ -7,7 +7,7 @@ const is = require('is-type-of');
|
|
|
7
7
|
const bytenode = require('bytenode');
|
|
8
8
|
const crypto = require('crypto');
|
|
9
9
|
const JavaScriptObfuscator = require('javascript-obfuscator');
|
|
10
|
-
const UtilsJson = require('../
|
|
10
|
+
const UtilsJson = require('../utils/json');
|
|
11
11
|
|
|
12
12
|
class Encrypt {
|
|
13
13
|
constructor() {
|
package/module/utils/helper.js
CHANGED
package/module/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"bin": {
|
|
12
|
-
"ee-core": "./bin/tools.js"
|
|
12
|
+
"ee-core": "./module/bin/tools.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"agentkeepalive": "^4.2.0",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"mkdirp": "^2.1.3",
|
|
38
38
|
"path-to-regexp": "^6.2.0",
|
|
39
|
+
"serialize-javascript": "^6.0.1",
|
|
39
40
|
"socket.io": "^4.4.1",
|
|
40
41
|
"socket.io-client": "^4.4.1",
|
|
41
42
|
"urllib": "^2.38.0"
|