MCPcopy Create free account
hub / github.com/microsoft/vscode-languageserver-node / setupExitTimer

Function setupExitTimer

server/src/main.ts:75–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73let exitTimer: NodeJS.Timer | undefined = undefined;
74
75function setupExitTimer(): void {
76 const argName = '--clientProcessId';
77 function runTimer(value: string): void {
78 try {
79 let processId = parseInt(value);
80 if (!isNaN(processId)) {
81 exitTimer = setInterval(() => {
82 try {
83 process.kill(processId, <any>0);
84 } catch (ex) {
85 // Parent process doesn't exist anymore. Exit the server.
86 process.exit(shutdownReceived ? 0 : 1);
87 }
88 }, 3000);
89 }
90 } catch (e) {
91 // Ignore errors;
92 }
93 }
94
95 for (let i = 2; i < process.argv.length; i++) {
96 let arg = process.argv[i];
97 if (arg === argName && i + 1 < process.argv.length) {
98 runTimer(process.argv[i + 1]);
99 return;
100 } else {
101 let args = arg.split('=');
102 if (args[0] === argName) {
103 runTimer(args[1]);
104 }
105 }
106 }
107}
108setupExitTimer();
109
110function null2Undefined<T>(value: T | null): T | undefined {

Callers 1

main.tsFile · 0.85

Calls 1

runTimerFunction · 0.85

Tested by

no test coverage detected