report typings installer process id to parent process
This commit is contained in:
parent
66c1178134
commit
f48728af74
1 changed files with 20 additions and 1 deletions
|
@ -40,6 +40,7 @@ namespace ts.server {
|
||||||
send(message: any, sendHandle?: any): void;
|
send(message: any, sendHandle?: any): void;
|
||||||
on(message: "message", f: (m: any) => void): void;
|
on(message: "message", f: (m: any) => void): void;
|
||||||
kill(): void;
|
kill(): void;
|
||||||
|
pid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NodeSocket {
|
interface NodeSocket {
|
||||||
|
@ -179,6 +180,7 @@ namespace ts.server {
|
||||||
|
|
||||||
class NodeTypingsInstaller implements ITypingsInstaller {
|
class NodeTypingsInstaller implements ITypingsInstaller {
|
||||||
private installer: NodeChildProcess;
|
private installer: NodeChildProcess;
|
||||||
|
private installerPidReported = false;
|
||||||
private socket: NodeSocket;
|
private socket: NodeSocket;
|
||||||
private projectService: ProjectService;
|
private projectService: ProjectService;
|
||||||
|
|
||||||
|
@ -190,10 +192,25 @@ namespace ts.server {
|
||||||
if (eventPort) {
|
if (eventPort) {
|
||||||
const s = net.connect({ port: eventPort }, () => {
|
const s = net.connect({ port: eventPort }, () => {
|
||||||
this.socket = s;
|
this.socket = s;
|
||||||
|
this.reportInstallerProcessId();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private reportInstallerProcessId() {
|
||||||
|
if (this.installerPidReported) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.socket && this.installer) {
|
||||||
|
this.sendEvent(0, "typingsInstallerPid", { pid: this.installer.pid });
|
||||||
|
this.installerPidReported = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private sendEvent(seq: number, event: string, body: any): void {
|
||||||
|
this.socket.write(formatMessage({ seq, type: "event", event, body }, this.logger, Buffer.byteLength, this.newLine), "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
attach(projectService: ProjectService) {
|
attach(projectService: ProjectService) {
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
if (this.logger.hasLevel(LogLevel.requestTime)) {
|
if (this.logger.hasLevel(LogLevel.requestTime)) {
|
||||||
|
@ -222,6 +239,8 @@ namespace ts.server {
|
||||||
|
|
||||||
this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv });
|
this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv });
|
||||||
this.installer.on("message", m => this.handleMessage(m));
|
this.installer.on("message", m => this.handleMessage(m));
|
||||||
|
this.reportInstallerProcessId();
|
||||||
|
|
||||||
process.on("exit", () => {
|
process.on("exit", () => {
|
||||||
this.installer.kill();
|
this.installer.kill();
|
||||||
});
|
});
|
||||||
|
@ -245,7 +264,7 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
this.projectService.updateTypingsForProject(response);
|
this.projectService.updateTypingsForProject(response);
|
||||||
if (response.kind == "set" && this.socket) {
|
if (response.kind == "set" && this.socket) {
|
||||||
this.socket.write(formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8");
|
this.sendEvent(0, "setTypings", response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue