Skip to content

Commit eaf56ac

Browse files
committed
change process kill approach
1 parent accc795 commit eaf56ac

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

lib/exec.proc.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable sonarjs/cognitive-complexity */
2-
import { isFunction, isAsyncFunction, isNumber, millisecondsToMinutes, isString, isBoolean } from 'sat-utils';
2+
import { isFunction, isAsyncFunction, isNumber, millisecondsToMinutes, isString, isBoolean, sleep } from 'sat-utils';
33
import { internalLogProcessResult } from './logger.execution';
44
import { execute } from './exec';
55
import { logger } from './logger';
@@ -39,15 +39,16 @@ function buildExecRunner(notRetriable, runOpts) {
3939
}
4040
const execProc = execute(cmd, logProcessResult, executionHolder, execOpts);
4141

42-
const killTooLongExecution = procWhatShouldBeKilled => {
42+
const killTooLongExecution = (procWhatShouldBeKilled: typeof execProc) => {
4343
const executionTime = +Date.now() - startTime;
4444
if (executionTime > longestProcessTime) {
45-
if (executionTime - longestProcessTime > 5000) {
45+
if (executionTime - longestProcessTime > 7500) {
4646
procWhatShouldBeKilled.emit('exit', 100, 'PRO_RERUN_KILL');
4747
procWhatShouldBeKilled.emit('close', 100, 'PRO_RERUN_KILL');
48+
logger.error(`Process just marked manually as killed but it is possible that it is still running`);
4849
} else {
49-
logger.info(`Process killed due to long time execution: ${millisecondsToMinutes(executionTime)}`);
50-
procWhatShouldBeKilled.kill('SIGKILL');
50+
logger.info(`Process killed due to long time execution: ${millisecondsToMinutes(executionTime)}\n${cmd}}`);
51+
process.kill(procWhatShouldBeKilled.pid);
5152
}
5253
}
5354
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "process-rerun",
3-
"version": "0.4.2",
3+
"version": "0.4.3",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/potapovDim/protractor-rerun.git"

0 commit comments

Comments
 (0)