mirror of
https://github.com/wallace5303/ee-core.git
synced 2026-04-05 07:29:04 +08:00
[feat] [ee-core] kill children process
This commit is contained in:
@@ -10,6 +10,7 @@ const { getRandomString, getValueFromArgv } = require('../utils/helper');
|
||||
const { is } = require('../utils');
|
||||
const { parseArgv } = require('../utils/pargv');
|
||||
const { app: electronApp } = require('electron');
|
||||
const tkill = require('tree-kill');
|
||||
|
||||
class CrossProcess {
|
||||
constructor(host, opt = {}) {
|
||||
@@ -116,11 +117,15 @@ class CrossProcess {
|
||||
* kill
|
||||
*/
|
||||
kill(timeout = 1000) {
|
||||
this.child.kill('SIGINT');
|
||||
setTimeout(() => {
|
||||
if (this.child.killed) return;
|
||||
this.child.kill('SIGKILL');
|
||||
}, timeout)
|
||||
tkill(this.pid, 'SIGINT', (err) => {
|
||||
if (err) {
|
||||
coreLogger.error(`[ee-core] [corss/process] kill cross-process, error: ${err}, pid:${this.pid}`);
|
||||
tkill(this.pid, 'SIGKILL');
|
||||
}
|
||||
setTimeout(() => {
|
||||
this._exitElectron();
|
||||
}, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ee-core",
|
||||
"version": "4.0.0",
|
||||
"version": "4.0.1",
|
||||
"description": "ee core",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -33,6 +33,7 @@
|
||||
"serialize-javascript": "^6.0.1",
|
||||
"socket.io": "^4.6.1",
|
||||
"socket.io-client": "^4.6.1",
|
||||
"tree-kill": "^1.2.2",
|
||||
"urllib": "^2.38.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user