-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
41 lines (39 loc) · 1.57 KB
/
main.ts
File metadata and controls
41 lines (39 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox and others.
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */
import { resolve } from 'path';
import { runLanguageServer } from '../../common/language-server-runner.js';
import { IncomingMessage } from 'http';
import { LanguageName } from '../../common/server-commons.js';
export const runPythonServer = (baseDir: string, relativeDir: string) => {
const processRunPath = resolve(baseDir, relativeDir);
console.log(processRunPath);
runLanguageServer({
serverName: 'PYRIGHT',
pathName: '/pyright',
serverPort: 30001,
runCommand: LanguageName.node,
runCommandArgs: [
processRunPath,
'--stdio'
],
wsServerOptions: {
noServer: true,
perMessageDeflate: false,
clientTracking: true,
verifyClient: (
clientInfo: { origin: string; secure: boolean; req: IncomingMessage },
callback
) => {
const parsedURL = new URL(`${clientInfo.origin}${clientInfo.req?.url ?? ''}`);
const authToken = parsedURL.searchParams.get('authorization');
if (authToken === 'UserAuth') {
callback(true);
} else {
callback(false);
}
}
}
});
};