|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
|
| 7 | +import { parsePtyHostDebugPort } from 'vs/platform/environment/node/environmentService'; |
| 8 | +import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; |
| 9 | +import { ILogService } from 'vs/platform/log/common/log'; |
| 10 | +import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; |
7 | 11 | import { IReconnectConstants } from 'vs/platform/terminal/common/terminal';
|
8 |
| -import { NodePtyHostStarter } from 'vs/platform/terminal/node/nodePtyHostStarter'; |
9 | 12 | import { IPtyHostConnection, IPtyHostStarter } from 'vs/platform/terminal/node/ptyHost';
|
10 |
| -// import { FileAccess } from 'vs/base/common/network'; |
11 |
| -// import { Client, IIPCOptions } from 'vs/base/parts/ipc/node/ipc.cp'; |
12 |
| -// import { parsePtyHostDebugPort } from 'vs/platform/environment/node/environmentService'; |
13 |
| -// import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess'; |
| 13 | +import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess'; |
| 14 | +import { Client as MessagePortClient } from 'vs/base/parts/ipc/electron-main/ipc.mp'; |
14 | 15 |
|
15 | 16 | export class ElectronPtyHostStarter implements IPtyHostStarter {
|
16 | 17 |
|
17 |
| - // private utilityProcess: UtilityProcess | undefined = undefined; |
| 18 | + private utilityProcess: UtilityProcess | undefined = undefined; |
18 | 19 |
|
19 | 20 | constructor(
|
20 | 21 | private readonly _reconnectConstants: IReconnectConstants,
|
21 |
| - @IEnvironmentService private readonly _environmentService: INativeEnvironmentService |
| 22 | + @IEnvironmentService private readonly _environmentService: INativeEnvironmentService, |
| 23 | + @ILifecycleMainService private readonly _lifecycleMainService: ILifecycleMainService, |
| 24 | + @ILogService private readonly _logService: ILogService |
22 | 25 | ) {
|
23 | 26 | }
|
24 | 27 |
|
25 |
| - start(lastPtyId: number): IPtyHostConnection { |
26 |
| - return new NodePtyHostStarter(this._reconnectConstants, this._environmentService).start(lastPtyId); |
27 |
| - |
28 |
| - // console.log('use utility proc'); |
29 |
| - |
30 |
| - // // TODO: Convert to use utility process |
31 |
| - // const opts: IIPCOptions = { |
32 |
| - // serverName: 'Pty Host', |
33 |
| - // args: ['--type=ptyHost', '--logsPath', this._environmentService.logsHome.fsPath], |
34 |
| - // env: { |
35 |
| - // VSCODE_LAST_PTY_ID: lastPtyId, |
36 |
| - // VSCODE_PTY_REMOTE: this._isRemote, |
37 |
| - // VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', |
38 |
| - // VSCODE_PIPE_LOGGING: 'true', |
39 |
| - // VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client, |
40 |
| - // VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime, |
41 |
| - // VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.shortGraceTime, |
42 |
| - // VSCODE_RECONNECT_SCROLLBACK: this._reconnectConstants.scrollback |
43 |
| - // } |
44 |
| - // }; |
45 |
| - |
46 |
| - // const ptyHostDebug = parsePtyHostDebugPort(this._environmentService.args, this._environmentService.isBuilt); |
47 |
| - // if (ptyHostDebug) { |
48 |
| - // if (ptyHostDebug.break && ptyHostDebug.port) { |
49 |
| - // opts.debugBrk = ptyHostDebug.port; |
50 |
| - // } else if (!ptyHostDebug.break && ptyHostDebug.port) { |
51 |
| - // opts.debug = ptyHostDebug.port; |
52 |
| - // } |
53 |
| - // } |
54 |
| - |
55 |
| - // const client = new Client(FileAccess.asFileUri('bootstrap-fork').fsPath, opts); |
56 |
| - |
57 |
| - // return { |
58 |
| - // client, |
59 |
| - // dispose: client.dispose, |
60 |
| - // onDidProcessExit: client.onDidProcessExit |
61 |
| - // }; |
| 28 | + async start(lastPtyId: number): Promise<IPtyHostConnection> { |
| 29 | + this.utilityProcess = new UtilityProcess(this._logService, NullTelemetryService, this._lifecycleMainService); |
| 30 | + |
| 31 | + const inspectParams = parsePtyHostDebugPort(this._environmentService.args, this._environmentService.isBuilt); |
| 32 | + let execArgv: string[] | undefined = undefined; |
| 33 | + if (inspectParams) { |
| 34 | + execArgv = ['--nolazy']; |
| 35 | + if (inspectParams.break) { |
| 36 | + execArgv.push(`--inspect-brk=${inspectParams.port}`); |
| 37 | + } else if (!inspectParams.break) { |
| 38 | + execArgv.push(`--inspect=${inspectParams.port}`); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + this.utilityProcess.start({ |
| 43 | + type: 'ptyHost', |
| 44 | + entryPoint: 'vs/platform/terminal/node/ptyHostMain', |
| 45 | + payload: this._createPtyHostConfiguration(lastPtyId), |
| 46 | + execArgv |
| 47 | + }); |
| 48 | + |
| 49 | + const port = this.utilityProcess.connect(); |
| 50 | + const client = new MessagePortClient(port, 'ptyHost'); |
| 51 | + |
| 52 | + return { |
| 53 | + client, |
| 54 | + dispose: client.dispose, |
| 55 | + onDidProcessExit: this.utilityProcess.onExit |
| 56 | + }; |
| 57 | + } |
| 58 | + |
| 59 | + private _createPtyHostConfiguration(lastPtyId: number) { |
| 60 | + return { |
| 61 | + VSCODE_LAST_PTY_ID: lastPtyId, |
| 62 | + VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', |
| 63 | + VSCODE_PIPE_LOGGING: 'true', |
| 64 | + VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client, |
| 65 | + VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime, |
| 66 | + VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.shortGraceTime, |
| 67 | + VSCODE_RECONNECT_SCROLLBACK: this._reconnectConstants.scrollback |
| 68 | + }; |
62 | 69 | }
|
63 | 70 | }
|
0 commit comments