ee-core 2.8.0-beta.1 → 2.8.0-beta.2

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.
@@ -1,13 +1,12 @@
1
1
  const EventEmitter = require('events');
2
2
  const path = require('path');
3
3
  const crossSpawn = require('cross-spawn');
4
- const serialize = require('serialize-javascript');
5
- const { app: electronApp } = require('electron');
6
4
  const Log = require('../log');
7
5
  const Ps = require('../ps');
8
6
  const Channel = require('../const/channel');
9
7
  const Helper = require('../utils/helper');
10
8
  const UtilsPargv = require('../utils/pargv');
9
+ const EE = require('../ee');
11
10
 
12
11
  class SpawnProcess {
13
12
  constructor(host, opt = {}) {
@@ -47,28 +46,6 @@ class SpawnProcess {
47
46
  });
48
47
  this.child = coreProcess;
49
48
  this.pid = coreProcess.pid;
50
- coreProcess.on('close', (code, signal) => {
51
- Log.coreLogger.info(`[ee-core] [cross/process] received a close from child-process, code:${code}, signal:${signal}, pid:${this.pid}`);
52
-
53
- // electron quit
54
- if (this.config.appExit) {
55
- setTimeout(() => {
56
- // 进程退出前的一些清理工作
57
- electronApp.quit();
58
- }, 1000)
59
- }
60
- });
61
-
62
- coreProcess.on('message', (m) => {
63
- Log.coreLogger.info(`[ee-core] [corss/process] received a message from child-process, message: ${serialize(m)}`);
64
-
65
- if (!m || !m.id) {
66
- return;
67
- }
68
-
69
- // 收到子进程消息,转发到 event
70
- //this.emitter.emit(m.event, m.data);
71
- });
72
49
 
73
50
  coreProcess.on('exit', (code, signal) => {
74
51
  let data = {
@@ -76,6 +53,7 @@ class SpawnProcess {
76
53
  }
77
54
  this.host.emitter.emit(Channel.events.childProcessExit, data);
78
55
  Log.coreLogger.info(`[ee-core] [corss/process] received a exit from child-process, code:${code}, signal:${signal}, pid:${this.pid}`);
56
+ this._exitElectron();
79
57
  });
80
58
 
81
59
  coreProcess.on('error', (err) => {
@@ -84,6 +62,7 @@ class SpawnProcess {
84
62
  }
85
63
  this.host.emitter.emit(Channel.events.childProcessError, data);
86
64
  Log.coreLogger.error(`[ee-core] [corss/process] received a error from child-process, error: ${err}, pid:${this.pid}`);
65
+ this._exitElectron();
87
66
  });
88
67
  }
89
68
 
@@ -128,6 +107,19 @@ class SpawnProcess {
128
107
  const obj = UtilsPargv(this.config.args);
129
108
  return obj;
130
109
  }
110
+
111
+ /**
112
+ * exit electron
113
+ */
114
+ _exitElectron(timeout = 1000) {
115
+ const { CoreApp } = EE;
116
+ if (this.config.appExit) {
117
+ setTimeout(() => {
118
+ // 进程退出前的一些清理工作
119
+ CoreApp.appQuit();
120
+ }, timeout)
121
+ }
122
+ }
131
123
  }
132
124
 
133
125
  module.exports = SpawnProcess;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "2.8.0-beta.1",
3
+ "version": "2.8.0-beta.2",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {