[feat] [ee-core] kill children process

This commit is contained in:
gaoshuaixing
2025-02-24 16:43:26 +08:00
parent 217ac6f5d8
commit 93d2b774e6
2 changed files with 12 additions and 6 deletions

View File

@@ -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() {

View File

@@ -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": {