Unverified Commit 62d5812d authored by J-shang's avatar J-shang Committed by GitHub
Browse files

quick fix kill command under windows (#3106)

parent 604f8431
......@@ -34,7 +34,8 @@ def check_output_command(file_path, head=None, tail=None):
def kill_command(pid):
"""kill command"""
if sys.platform == 'win32':
psutil.Process(pid).terminate()
process = psutil.Process(pid=pid)
process.send_signal(signal.CTRL_BREAK_EVENT)
else:
cmds = ['kill', str(pid)]
call(cmds)
......
......@@ -179,20 +179,7 @@ mkDirP(getLogDir())
console.error(`Failed to create log dir: ${err.stack}`);
});
function getStopSignal(): any {
return 'SIGTERM';
}
function getCtrlCSignal(): any {
return 'SIGINT';
}
process.on(getCtrlCSignal(), async () => {
const log: Logger = getLogger();
log.info(`Get SIGINT signal!`);
});
process.on(getStopSignal(), async () => {
async function cleanUp(): Promise<void> {
const log: Logger = getLogger();
let hasError: boolean = false;
try {
......@@ -206,7 +193,11 @@ process.on(getStopSignal(), async () => {
hasError = true;
log.error(`${err.stack}`);
} finally {
await log.close();
log.close();
process.exit(hasError ? 1 : 0);
}
});
}
process.on('SIGTERM', cleanUp);
process.on('SIGBREAK', cleanUp);
process.on('SIGINT', cleanUp);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment