ee-core 2.0.0-beta.3 → 2.0.0-beta.6

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.
Files changed (68) hide show
  1. package/addon/index.js +30 -0
  2. package/config/config.default.js +2 -3
  3. package/config/index.js +54 -0
  4. package/const/channel.js +9 -0
  5. package/{module/const → const}/index.js +1 -5
  6. package/controller/index.js +34 -0
  7. package/core/index.js +0 -2
  8. package/core/lib/ee.js +0 -2
  9. package/core/lib/loader/ee_loader.js +2 -2
  10. package/core/lib/loader/file_loader.js +1 -0
  11. package/{lib → ee}/application.js +2 -2
  12. package/{lib → ee}/baseApp.js +5 -4
  13. package/{lib → ee}/eeApp.js +21 -47
  14. package/ee/index.js +30 -0
  15. package/electron/index.js +32 -0
  16. package/electron/window.js +45 -0
  17. package/exception/index.js +85 -0
  18. package/{module/httpclient → httpclient}/index.js +2 -2
  19. package/index.js +8 -10
  20. package/jobs/baseJobClass.js +16 -0
  21. package/jobs/child/app.js +63 -0
  22. package/jobs/child/forkProcess.js +61 -0
  23. package/jobs/child/index.js +78 -0
  24. package/jobs/childPool/app.js +68 -0
  25. package/{module/jobs/child → jobs/childPool}/forkProcess.js +15 -16
  26. package/{module/jobs/child → jobs/childPool}/index.js +27 -17
  27. package/{module/jobs/child → jobs/childPool}/pool.js +3 -3
  28. package/{module/jobs → jobs}/renderer/loadView.js +1 -1
  29. package/{module/jobs → jobs}/unification.js +1 -1
  30. package/{module/loader → loader}/index.js +36 -14
  31. package/{module/log → log}/logger.js +1 -1
  32. package/message/childMessage.js +31 -0
  33. package/{module/message → message}/index.js +2 -11
  34. package/{module/utils → oldUtils}/index.js +25 -5
  35. package/package.json +2 -1
  36. package/{module/utils/ps.js → ps/index.js} +30 -3
  37. package/service/index.js +34 -0
  38. package/{module/socket → socket}/httpServer.js +12 -18
  39. package/socket/index.js +82 -0
  40. package/{module/socket → socket}/io.js +6 -2
  41. package/{module/socket → socket}/ipcServer.js +2 -4
  42. package/socket/socketServer.js +66 -0
  43. package/{module/storage → storage}/jsondbStorage.js +38 -1
  44. package/{module/storage → storage}/sqliteStorage.js +1 -1
  45. package/tools/encrypt.js +1 -1
  46. package/{module/utils → utils}/helper.js +0 -1
  47. package/utils/index.js +7 -27
  48. package/module/exception/index.js +0 -16
  49. package/module/jobs/child/app.js +0 -43
  50. package/module/message/childMessage.js +0 -63
  51. package/module/message/ipcMain.js +0 -160
  52. package/module/message/ipcRender.js +0 -0
  53. package/module/message/manager.js +0 -0
  54. package/module/message/messenger.js +0 -0
  55. package/module/socket/socketClient.js +0 -49
  56. package/module/socket/socketServer.js +0 -76
  57. package/module/socket/start.js +0 -22
  58. /package/{lib → ee}/appLoader.js +0 -0
  59. /package/{module/jobs → jobs}/index.js +0 -0
  60. /package/{module/jobs → jobs}/renderer/index.js +0 -0
  61. /package/{module/log → log}/index.js +0 -0
  62. /package/{module/storage → storage}/index.js +0 -0
  63. /package/{module/storage → storage}/jsondb/adapters/Base.js +0 -0
  64. /package/{module/storage → storage}/jsondb/adapters/FileSync.js +0 -0
  65. /package/{module/storage → storage}/jsondb/main.js +0 -0
  66. /package/{module/utils → utils}/copyto.js +0 -0
  67. /package/{module/utils → utils}/json.js +0 -0
  68. /package/{module/utils → utils}/wrap.js +0 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * BaseJobClass
3
+ */
4
+ class BaseJobClass {
5
+
6
+ /**
7
+ * @class
8
+ * @param {Object} params - job基础类
9
+ * @since 1.0.0
10
+ */
11
+ constructor(params = {}) {
12
+ // todo
13
+ }
14
+ }
15
+
16
+ module.exports = BaseJobClass;
@@ -0,0 +1,63 @@
1
+
2
+ const is = require('is-type-of');
3
+ let Exception;
4
+ let Loader;
5
+ let Log;
6
+ let UtilsCore;
7
+
8
+ // 开发环境下,ee-core是soft link
9
+ if (__dirname.indexOf("node_modules") == -1) {
10
+ Exception = require('../../exception');
11
+ Loader = require('../../loader');
12
+ Log = require('../../log');
13
+ UtilsCore = require('../../core/lib/utils');
14
+ } else {
15
+ Exception = require('ee-core/exception');
16
+ Loader = require('ee-core/loader');
17
+ Log = require('ee-core/log');
18
+ UtilsCore = require('../../core/lib/utils');
19
+ }
20
+
21
+ Exception.start();
22
+
23
+ class ChildApp {
24
+ constructor() {
25
+ this._initEvents();
26
+ }
27
+
28
+ /**
29
+ * 初始化事件监听
30
+ */
31
+ _initEvents() {
32
+ process.on('message', this._handleMessage.bind(this));
33
+ process.on('exit', (code) => {
34
+ Log.coreLogger.info(`[ee-core] [jobs/child] received a exit from main-process, code:${code}, pid:${process.pid}`);
35
+ });
36
+ }
37
+
38
+ /**
39
+ * 监听消息
40
+ */
41
+ _handleMessage(m) {
42
+ this.run(m);
43
+ Log.coreLogger.info(`[ee-core] [jobs/child] received a message from main-process, message: ${JSON.stringify(m)}`);
44
+ }
45
+
46
+ /**
47
+ * 运行脚本
48
+ */
49
+ run(msg = {}) {
50
+ let filepath = msg.jobPath;
51
+ let params = msg.jobParams;
52
+
53
+ let mod = Loader.loadJsFile(filepath);
54
+ if (is.class(mod) || UtilsCore.isBytecodeClass(mod)) {
55
+ let jobClass = new mod(params);
56
+ jobClass.handle();
57
+ } else if (is.function(mod)) {
58
+ mod(params);
59
+ }
60
+ }
61
+ }
62
+
63
+ new ChildApp();
@@ -0,0 +1,61 @@
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] received a message from child-process, message: ${serialize(m)}`);
39
+ if (m.channel == Channel.process.showException) {
40
+ Log.coreLogger.error(`${m.data}`);
41
+ }
42
+
43
+ // 收到子进程消息,转发到 event
44
+ if (m.channel == Channel.process.sendToMain) {
45
+ this.host.emit(m.event, m.data);
46
+ }
47
+
48
+ });
49
+
50
+ this.child.on('exit', (code, signal) => {
51
+ Log.coreLogger.info(`[ee-core] [jobs/child] received a exit from child-process, code:${code}, signal:${signal}`);
52
+ });
53
+
54
+ this.child.on('error', (err) => {
55
+ Log.coreLogger.error(`[ee-core] [jobs/child] received a error from child-process, error: ${err} !`);
56
+ });
57
+ }
58
+
59
+ }
60
+
61
+ module.exports = ForkProcess;
@@ -0,0 +1,78 @@
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.initEvents();
14
+ }
15
+
16
+ /**
17
+ * 初始化监听
18
+ */
19
+ initEvents = () => {
20
+
21
+ // this.on('forked_message', ({data, id}) => {
22
+ // this.onMessage({data, id});
23
+ // });
24
+ }
25
+
26
+ /**
27
+ * 执行一个job文件
28
+ */
29
+ exec(filepath, params = {}, opt = {}) {
30
+ const jobPath = this._getFullpath(filepath);
31
+
32
+ // 消息对象
33
+ const mid = Helper.getRandomString();
34
+ let msg = {
35
+ mid,
36
+ jobPath,
37
+ jobParams: params
38
+ }
39
+
40
+ let subProcess = new ForkProcess(this, opt);
41
+
42
+ // todo 是否会发生监听未完成时,接收不到消息?
43
+ // 发消息到子进程
44
+ subProcess.child.send(msg);
45
+
46
+ return subProcess;
47
+ }
48
+
49
+ /**
50
+ * todo 运行job
51
+ */
52
+ run(name, filepath, opt = {}) {
53
+ let times = opt.times || 1;
54
+
55
+ for (let i = 1; i <= times; i++) {
56
+ this.exec(filepath, opt);
57
+ }
58
+
59
+ return;
60
+ }
61
+
62
+ _getFullpath(filepath) {
63
+ const isAbsolute = path.isAbsolute(filepath);
64
+ if (!isAbsolute) {
65
+ filepath = path.join(Ps.getBaseDir(), filepath);
66
+ }
67
+
68
+ const fullpath = Loader.resolveModule(filepath);
69
+ if (!fs.existsSync(fullpath)) {
70
+ throw new Error(`[ee-core] [jobs/child] file ${fullpath} not exists`);
71
+ }
72
+
73
+ return fullpath;
74
+ }
75
+
76
+ }
77
+
78
+ module.exports = ChildJob;
@@ -0,0 +1,68 @@
1
+
2
+ const is = require('is-type-of');
3
+ let Exception;
4
+ let Loader;
5
+ let Log;
6
+ let UtilsCore;
7
+
8
+ // 开发环境下,ee-core是soft link
9
+ if (__dirname.indexOf("node_modules") == -1) {
10
+ Exception = require('../../exception');
11
+ Loader = require('../../loader');
12
+ Log = require('../../log');
13
+ UtilsCore = require('../../core/lib/utils');
14
+ } else {
15
+ Exception = require('ee-core/exception');
16
+ Loader = require('ee-core/loader');
17
+ Log = require('ee-core/log');
18
+ UtilsCore = require('../../core/lib/utils');
19
+ }
20
+
21
+ Exception.start();
22
+
23
+ class ChildApp {
24
+ constructor() {
25
+ this._initEvents();
26
+ }
27
+
28
+ /**
29
+ * 初始化事件监听
30
+ */
31
+ _initEvents() {
32
+ process.on('message', this._handleMessage.bind(this));
33
+ process.on('disconnect', () => {
34
+ Log.coreLogger.info(`[ee-core] [jobs/child] child process disconnected, pid:${process.pid}`);
35
+ });
36
+ process.on('exit', (code) => {
37
+ Log.coreLogger.info(`[ee-core] [jobs/child] child process exit code:${code}, pid:${process.pid}`);
38
+ });
39
+ }
40
+
41
+ /**
42
+ * 监听消息
43
+ */
44
+ _handleMessage(m) {
45
+ this.run(m);
46
+ Log.coreLogger.info(`[ee-core] [jobs/child] Received a message ${JSON.stringify(m)} from the mainProcess`);
47
+ }
48
+
49
+ /**
50
+ * 运行脚本
51
+ */
52
+ run(msg = {}) {
53
+ let filepath = msg.jobPath;
54
+ let params = msg.params;
55
+
56
+ let mod = Loader.loadJsFile(filepath);
57
+ if (is.class(mod) || UtilsCore.isBytecodeClass(mod)) {
58
+ let jobClass = new mod(params);
59
+ jobClass.handle();
60
+ } else if (is.function(mod)) {
61
+ mod(params);
62
+ }
63
+
64
+ Log.coreLogger.info('[ee-core] [child-process] job run');
65
+ }
66
+ }
67
+
68
+ new ChildApp();
@@ -1,20 +1,16 @@
1
1
  const path = require('path');
2
2
  const { fork } = require('child_process');
3
+ const serialize = require('serialize-javascript');
3
4
  const Log = require('../../log');
4
- const Ps = require('../../utils/ps');
5
+ const Ps = require('../../ps');
6
+ const Channel = require('../../const/channel');
5
7
 
6
8
  class ForkProcess {
7
9
  constructor(host, opt = {}) {
8
-
9
- let processCWD = Ps.getHomeDir();
10
- // if (Ps.isDev()) {
11
- // cwd = path.join(Ps.getHomeDir());
12
- // }
13
-
10
+
14
11
  let options = Object.assign({
15
- params: {},
16
12
  processOptions: {
17
- cwd: processCWD,
13
+ cwd: Ps.getHomeDir(),
18
14
  env: Ps.allEnv(),
19
15
  stdio: 'pipe'
20
16
  }
@@ -25,7 +21,7 @@ class ForkProcess {
25
21
  this.sleeping = false;
26
22
 
27
23
  // 传递给子进程的参数
28
- this.args.push(JSON.stringify(options.params));
24
+ //this.args.push(JSON.stringify(options.params));
29
25
 
30
26
  const appPath = path.join(__dirname, 'app.js');
31
27
  this.child = fork(appPath, this.args, options.processOptions);
@@ -38,24 +34,27 @@ class ForkProcess {
38
34
  * 进程初始化
39
35
  */
40
36
  _init() {
41
- this.child.on('message', (data) => {
42
- Log.coreLogger.info(`[ee-core] [module/jobs/child/forkProcess] from childProcess event-message ${data}`);
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
+ }
43
42
  });
44
43
 
45
44
  this.child.on('disconnect', () => {
46
- Log.coreLogger.info(`[ee-core] [module/jobs/child/forkProcess] from childProcess event-disconnect !`);
45
+ Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-disconnect !`);
47
46
  });
48
47
 
49
48
  this.child.on('close', (code, signal) => {
50
- Log.coreLogger.info(`[ee-core] [module/jobs/child/forkProcess] from childProcess event-close code:${code}, signal:${signal}`);
49
+ Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-close code:${code}, signal:${signal}`);
51
50
  });
52
51
 
53
52
  this.child.on('exit', (code, signal) => {
54
- Log.coreLogger.info(`[ee-core] [module/jobs/child/forkProcess] from childProcess event-exit code:${code}, signal:${signal}`);
53
+ Log.coreLogger.info(`[ee-core] [jobs/child/forkProcess] from childProcess event-exit code:${code}, signal:${signal}`);
55
54
  });
56
55
 
57
56
  this.child.on('error', (err) => {
58
- Log.coreLogger.error(`[ee-core] [module/jobs/child/forkProcess] from childProcess event-error :${err} !`);
57
+ Log.coreLogger.error(`[ee-core] [jobs/child/forkProcess] from childProcess event-error: ${err} !`);
59
58
  });
60
59
  }
61
60
 
@@ -2,8 +2,9 @@ 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('../../utils/ps');
5
+ const Ps = require('../../ps');
6
6
  const Loader = require('../../loader');
7
+ const Helper = require('../../utils/helper');
7
8
 
8
9
  class ChildJob extends EventEmitter {
9
10
 
@@ -13,35 +14,44 @@ class ChildJob extends EventEmitter {
13
14
  }
14
15
 
15
16
  /**
16
- * 运行任务
17
+ * 执行一个job文件
17
18
  */
18
- run(name, filepath, opt = {}) {
19
-
19
+ exec(filepath, opt = {}) {
20
20
  const jobPath = this._getFullpath(filepath);
21
21
  let options = Object.assign({
22
- times: 1,
23
- params: {
24
- jobPath
25
- }
22
+ params: {},
26
23
  }, opt);
27
24
 
28
25
  // 消息对象
26
+ const mid = Helper.getRandomString();
29
27
  let msg = {
30
- jobPath: jobPath,
28
+ mid,
29
+ jobPath,
31
30
  params: options.params
32
31
  }
33
- let subProcess;
34
- for (let i = 1; i <= options.times; i++) {
35
- subProcess = new ForkProcess(this, options);
36
- this.jobList.set(name, i);
37
32
 
38
- // 发消息到子进程
39
- subProcess.child.send(msg);
40
- }
33
+ let subProcess = new ForkProcess(this, options);
34
+
35
+ // todo 是否会发生监听未完成时,接收不到消息?
36
+ // 发消息到子进程,
37
+ subProcess.child.send(msg);
41
38
 
42
39
  return subProcess;
43
40
  }
44
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
+
45
55
  _getFullpath(filepath) {
46
56
  const isAbsolute = path.isAbsolute(filepath);
47
57
  if (!isAbsolute) {
@@ -50,7 +60,7 @@ class ChildJob extends EventEmitter {
50
60
 
51
61
  const fullpath = Loader.resolveModule(filepath);
52
62
  if (!fs.existsSync(fullpath)) {
53
- throw new Error(`[ee-core] [module/jobs/child] file ${fullpath} not exists`);
63
+ throw new Error(`[ee-core] [jobs/child] file ${fullpath} not exists`);
54
64
  }
55
65
 
56
66
  return fullpath;
@@ -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('../../utils/ps');
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] [module/jobs/child] file ${fullpath} not exists`);
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] [module/jobs/child] process dose not exist ${pid}`);
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);
@@ -1,4 +1,4 @@
1
- const Ps = require('../../utils/ps');
1
+ const Ps = require('../../ps');
2
2
 
3
3
  /**
4
4
  * loadView 生成BrowserWindow的html content
@@ -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('../utils/ps');
5
+ const Ps = require('../ps');
6
6
  const Loader = require('../loader');
7
7
 
8
8
  class Jobs {
@@ -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('../../core/lib/utils');
5
- const Ps = require('../utils/ps');
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] [module/loader/index] loadOneFile ${filepath} does not exist`;
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
- * 加载job文件
39
+ * 加载js文件
40
40
  *
41
41
  * @param {String} filepath - fullpath
42
- * @param {Array} inject - pass rest arguments into the function when invoke
43
- * @return {Object} exports
42
+ * @return {Any} exports
44
43
  * @since 1.0.0
45
44
  */
46
- loadJobFile (filepath, ...inject) {
45
+ loadJsFile (filepath) {
47
46
  if (!fs.existsSync(filepath)) {
48
- let warnMsg = `[ee-core] [module/loader] loadJobFile ${filepath} does not exist`;
49
- Log.coreLogger.error(warnMsg);
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] [module/loader] resolveModule unknow filepath: ${files}`)
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] [module/loader] requireModule filepath: ${filepath} does not exist`;
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);
@@ -1,6 +1,6 @@
1
1
  const Loggers = require('egg-logger').EggLoggers;
2
2
  const assert = require('assert');
3
- const Ps = require('../utils/ps');
3
+ const Ps = require('../ps');
4
4
  const Storage = require('../storage');
5
5
 
6
6
  module.exports = {
@@ -0,0 +1,31 @@
1
+ const Channel = require('../const/channel');
2
+
3
+ class ChildMessage {
4
+ constructor() {
5
+ // ...
6
+ }
7
+
8
+ /**
9
+ * 向主进程发消息
10
+ */
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);
19
+ }
20
+
21
+ /**
22
+ * 进程退出
23
+ */
24
+ exit(code = 0) {
25
+ return process.exit(code);
26
+ }
27
+ }
28
+
29
+
30
+
31
+ module.exports = ChildMessage;
@@ -1,21 +1,14 @@
1
- const Ps = require('../utils/ps');
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] = Logger.create();
11
+ this[EEChildMessage] = new ChildMessage();
19
12
  }
20
13
 
21
14
  return this[EEChildMessage] || null;
@@ -23,6 +16,4 @@ const message = {
23
16
 
24
17
  };
25
18
 
26
-
27
-
28
19
  module.exports = message;