Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
support to restart 'attach' session. fixes microsoft/vscode#2103
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Feb 18, 2016
1 parent e07b461 commit 91c3d00
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"stopOnEntry": false,
"runtimeArgs": [ "--nolazy" ],
"args": [ "--server=4711" ],
//"env": { "VSCODE_NLS_CONFIG": "{\"locale\":\"pseudo\",\"availableLanguages\":{}}" },
"externalConsole": true,
"externalConsole": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out"
},
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"vscode": "^0.10.1"
},
"dependencies": {
"vscode-debugprotocol": "next",
"vscode-debugadapter": "next",
"vscode-debugprotocol": "1.6.0-pre8",
"vscode-debugadapter": "1.6.0-pre12",
"source-map": "^0.5.3",
"vscode-nls": "^1.0.4"
},
Expand Down Expand Up @@ -78,6 +78,8 @@
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
Expand Down Expand Up @@ -159,6 +161,11 @@
"description": "%node.attach.timeout.description%",
"default": 10000
},
"restart": {
"type": "boolean",
"description": "%node.attach.restart.description%",
"default": true
},
"sourceMaps": {
"type": "boolean",
"description": "%node.sourceMaps.description%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"node.attach.port.description": "Debug port to attach to. Default is 5858.",
"node.attach.address.description": "TCP/IP address of debug port (for node >= 5.0 only). Default is 'localhost'.",
"node.attach.timeout.description": "Retry for this number of milliseconds to connect to the node runtime. Default is 10000 ms.",
"node.attach.restart.description": "Restart session after node has terminated.",
"node.attach.localRoot.description": "The local source root that corresponds to the 'remoteRoot'.",
"node.attach.remoteRoot.description": "The source root of the remote host.",

Expand Down
14 changes: 12 additions & 2 deletions src/node/nodeDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export interface AttachRequestArguments extends CommonArguments {
address?: string;
/** Retry for this number of milliseconds to connect to the node runtime. */
timeout?: number;

/** Request frontend to restart session on termination. */
restart?: boolean;
/** Node's root directory. */
remoteRoot?: string;
/** VS Code's root directory. */
Expand Down Expand Up @@ -189,6 +190,7 @@ export class NodeDebugSession extends DebugSession {
private _externalConsole: boolean;
private _isTerminated: boolean;
private _inShutdown: boolean;
private _restartMode = false;
private _terminalProcess: CP.ChildProcess; // the terminal process or undefined
private _pollForNodeProcess = false;
private _nodeProcessId: number = -1; // pid of the node runtime
Expand Down Expand Up @@ -279,7 +281,11 @@ export class NodeDebugSession extends DebugSession {

if (!this._isTerminated) {
this._isTerminated = true;
this.sendEvent(new TerminatedEvent());
if (this._restartMode) {
this.sendEvent(new TerminatedEvent(true));
} else {
this.sendEvent(new TerminatedEvent());
}
}
}

Expand Down Expand Up @@ -551,6 +557,10 @@ export class NodeDebugSession extends DebugSession {
this._attachMode = true;
}

if (typeof args.restart === 'boolean') {
this._restartMode = args.restart;
}

if (args.localRoot) {
if (!FS.existsSync(args.localRoot)) {
this.sendErrorResponse(response, 2023, localize('VSND2023', "attribute 'localRoot' ('{path}') does not exist"), { path: args.localRoot });
Expand Down

0 comments on commit 91c3d00

Please sign in to comment.