Skip to content

Commit

Permalink
chore(launcher): add more logging to processKill (#6025)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Mar 31, 2021
1 parent f472c96 commit 16d98cb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/server/processLauncher.ts
Expand Up @@ -161,15 +161,21 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
options.log(`[pid=${spawnedProcess.pid}] <kill>`);
helper.removeEventListeners(listeners);
if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) {
options.log(`[pid=${spawnedProcess.pid}] <will force kill>`);
// Force kill the browser.
try {
if (process.platform === 'win32')
childProcess.execSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { stdio: 'ignore' });
else
if (process.platform === 'win32') {
const stdout = childProcess.execSync(`taskkill /pid ${spawnedProcess.pid} /T /F`);
options.log(`[pid=${spawnedProcess.pid}] taskkill output: ${stdout.toString()}`);
} else {
process.kill(-spawnedProcess.pid, 'SIGKILL');
}
} catch (e) {
options.log(`[pid=${spawnedProcess.pid}] exception while trying to kill process: ${e}`);
// the process might have already stopped
}
} else {
options.log(`[pid=${spawnedProcess.pid}] <skipped force kill spawnedProcess.killed=${spawnedProcess.killed} processClosed=${processClosed}>`);
}
cleanup();
}
Expand Down

0 comments on commit 16d98cb

Please sign in to comment.