Notebooks: More Jupyter Server Hardening (#5264)

* Do not rely on same starting port every time, misc

* put back to 5 seconds for process kill timeout

* extHostNotebook shutdown manager handle
This commit is contained in:
Chris LaFreniere
2019-04-30 14:13:04 -07:00
committed by GitHub
parent 0f12d15020
commit e72d0d03ed
4 changed files with 13 additions and 8 deletions

View File

@@ -86,8 +86,9 @@ export class ServerInstanceUtils {
try {
process.kill(childProcess.pid, 'SIGKILL');
} catch (error) {
console.log(error);
// All is fine.
if (!error || !error.code || (typeof error.code === 'string' && error.code !== 'ESRCH')) {
console.log(error);
}
}
}, 5000);
}
@@ -230,8 +231,8 @@ export class PerNotebookServerInstance implements IServerInstance {
return;
}
let notebookDirectory = this.getNotebookDirectory();
// Find a port in a given range. If run into trouble, got up 100 in range and search inside a larger range
let port = await ports.strictFindFreePort(new ports.StrictPortFindOptions(defaultPort, defaultPort + 100, defaultPort + 1000));
// Find a port in a given range. If run into trouble, try another port inside the given range
let port = await ports.strictFindFreePort(new ports.StrictPortFindOptions(defaultPort, defaultPort + 1000));
let token = await notebookUtils.getRandomToken();
this._uri = vscode.Uri.parse(`http://localhost:${port}/?token=${token}`);
this._port = port.toString();