"docs/source/vscode:/vscode.git/clone" did not exist on "325a5de3a9acc97534a4446ce9dd4147efcd61a0"
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): ...@@ -34,7 +34,8 @@ def check_output_command(file_path, head=None, tail=None):
def kill_command(pid): def kill_command(pid):
"""kill command""" """kill command"""
if sys.platform == 'win32': if sys.platform == 'win32':
psutil.Process(pid).terminate() process = psutil.Process(pid=pid)
process.send_signal(signal.CTRL_BREAK_EVENT)
else: else:
cmds = ['kill', str(pid)] cmds = ['kill', str(pid)]
call(cmds) call(cmds)
......
...@@ -179,20 +179,7 @@ mkDirP(getLogDir()) ...@@ -179,20 +179,7 @@ mkDirP(getLogDir())
console.error(`Failed to create log dir: ${err.stack}`); console.error(`Failed to create log dir: ${err.stack}`);
}); });
function getStopSignal(): any { async function cleanUp(): Promise<void> {
return 'SIGTERM';
}
function getCtrlCSignal(): any {
return 'SIGINT';
}
process.on(getCtrlCSignal(), async () => {
const log: Logger = getLogger();
log.info(`Get SIGINT signal!`);
});
process.on(getStopSignal(), async () => {
const log: Logger = getLogger(); const log: Logger = getLogger();
let hasError: boolean = false; let hasError: boolean = false;
try { try {
...@@ -206,7 +193,11 @@ process.on(getStopSignal(), async () => { ...@@ -206,7 +193,11 @@ process.on(getStopSignal(), async () => {
hasError = true; hasError = true;
log.error(`${err.stack}`); log.error(`${err.stack}`);
} finally { } finally {
await log.close(); log.close();
process.exit(hasError ? 1 : 0); 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