Get shared process socket path to the environment service
This commit is contained in:
parent
4eb9f87217
commit
36a2d26148
@ -42,12 +42,17 @@ export abstract class Client {
|
||||
private tasks: string[] = [];
|
||||
private finishedTaskCount = 0;
|
||||
private readonly loadTime: Time;
|
||||
private sharedProcessDataPromise: Promise<ISharedProcessData>;
|
||||
|
||||
public constructor() {
|
||||
logger.info("Loading IDE");
|
||||
|
||||
this.loadTime = time(2500);
|
||||
|
||||
this.sharedProcessDataPromise = new Promise((resolve): void => {
|
||||
client.onSharedProcessActive(resolve);
|
||||
});
|
||||
|
||||
const overlay = document.getElementById("overlay");
|
||||
const logo = document.getElementById("logo");
|
||||
const msgElement = overlay
|
||||
@ -168,10 +173,20 @@ export abstract class Client {
|
||||
return client.initData;
|
||||
}
|
||||
|
||||
/**
|
||||
* An event that fires every time the shared process (re-)starts.
|
||||
*/
|
||||
public get onSharedProcessActive(): Event<ISharedProcessData> {
|
||||
return client.onSharedProcessActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* A promise that resolves with *initial* shared process data.
|
||||
*/
|
||||
public get sharedProcessData(): Promise<ISharedProcessData> {
|
||||
return this.sharedProcessDataPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the IDE.
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ import * as path from "path";
|
||||
import * as WebSocket from "ws";
|
||||
import { createApp } from "./server";
|
||||
import { requireModule } from "./vscode/bootstrapFork";
|
||||
import { SharedProcess, SharedProcessState } from './vscode/sharedProcess';
|
||||
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
|
||||
|
||||
export class Entry extends Command {
|
||||
|
||||
@ -91,7 +91,7 @@ export class Entry extends Command {
|
||||
const app = createApp((app) => {
|
||||
app.use((req, res, next) => {
|
||||
res.on("finish", () => {
|
||||
logger.info(`\u001B[1m${req.method} ${res.statusCode} \u001B[0m${req.url}`, field("host", req.hostname), field("ip", req.ip));
|
||||
logger.debug(`\u001B[1m${req.method} ${res.statusCode} \u001B[0m${req.url}`, field("host", req.hostname), field("ip", req.ip));
|
||||
});
|
||||
|
||||
next();
|
||||
|
@ -1,11 +1,11 @@
|
||||
import "./fill/require";
|
||||
import * as paths from "./fill/paths";
|
||||
import "./fill/storageDatabase";
|
||||
import "./fill/windowsService";
|
||||
import * as paths from "./fill/paths";
|
||||
import "./fill/environmentService";
|
||||
import "./fill/dom";
|
||||
import "./vscode.scss";
|
||||
|
||||
import { createConnection } from "net";
|
||||
import { Client as IDEClient, IURI, IURIFactory } from "@coder/ide";
|
||||
|
||||
import { registerContextMenuListener } from "vs/base/parts/contextmenu/electron-main/contextmenu";
|
||||
@ -28,41 +28,32 @@ export class Client extends IDEClient {
|
||||
this.protocolPromise = new Promise((resolve): void => {
|
||||
this.protoResolve = resolve;
|
||||
});
|
||||
this.sharedProcessData.then((data) => {
|
||||
paths._paths.socketPath = data.socketPath;
|
||||
});
|
||||
this.initData.then((data) => {
|
||||
paths._paths.appData = data.dataDirectory;
|
||||
paths._paths.defaultUserData = data.dataDirectory;
|
||||
});
|
||||
}
|
||||
|
||||
protected initialize(): Promise<void> {
|
||||
this.task("Connect to shared process", 5, async () => {
|
||||
await new Promise((resolve, reject): void => {
|
||||
const listener = this.onSharedProcessActive((data) => {
|
||||
listener.dispose();
|
||||
const socket = createConnection(data.socketPath, resolve);
|
||||
socket.once("error", () => {
|
||||
reject();
|
||||
});
|
||||
this.protoResolve!(new Protocol(socket));
|
||||
});
|
||||
});
|
||||
}).catch(() => undefined);
|
||||
|
||||
registerContextMenuListener();
|
||||
|
||||
return this.task("Start workbench", 1000, async (initData) => {
|
||||
paths.paths.appData = initData.dataDirectory;
|
||||
paths.paths.defaultUserData = initData.dataDirectory;
|
||||
|
||||
return this.task("Start workbench", 1000, async (data) => {
|
||||
const { startup } = require("./startup");
|
||||
await startup({
|
||||
machineId: "1",
|
||||
windowId: this.windowId,
|
||||
logLevel: LogLevel.Info,
|
||||
mainPid: 1,
|
||||
appRoot: initData.dataDirectory,
|
||||
execPath: initData.tmpDirectory,
|
||||
appRoot: data.dataDirectory,
|
||||
execPath: data.tmpDirectory,
|
||||
userEnv: {},
|
||||
nodeCachedDataDir: initData.tmpDirectory,
|
||||
nodeCachedDataDir: data.tmpDirectory,
|
||||
perfEntries: [],
|
||||
_: [],
|
||||
folderUri: URI.file(initData.dataDirectory),
|
||||
folderUri: URI.file(data.dataDirectory),
|
||||
});
|
||||
|
||||
// TODO: Set notification service for retrying.
|
||||
|
13
packages/vscode/src/fill/environmentService.ts
Normal file
13
packages/vscode/src/fill/environmentService.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import * as paths from "./paths";
|
||||
import * as environment from "vs/platform/environment/node/environmentService";
|
||||
|
||||
export class EnvironmentService extends environment.EnvironmentService {
|
||||
|
||||
public get sharedIPCHandle(): string {
|
||||
return paths._paths.socketPath || super.sharedIPCHandle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
environment.EnvironmentService = EnvironmentService;
|
@ -1,7 +1,8 @@
|
||||
export const paths = {
|
||||
export const _paths = {
|
||||
appData: "/tmp",
|
||||
defaultUserData: "/tmp",
|
||||
socketPath: "/tmp/vscode-online.sock",
|
||||
};
|
||||
|
||||
export let getAppDataPath = (): string => paths.appData;
|
||||
export let getDefaultUserDataPath = (): string => paths.defaultUserData;
|
||||
export const getAppDataPath = (): string => _paths.appData;
|
||||
export const getDefaultUserDataPath = (): string => _paths.defaultUserData;
|
||||
|
@ -7,10 +7,7 @@ import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorksp
|
||||
import { URI } from "vs/base/common/uri";
|
||||
import { IRecentlyOpened } from "vs/platform/history/common/history";
|
||||
import { ISerializableCommandAction } from "vs/platform/actions/common/actions";
|
||||
|
||||
// TODO: Might make sense to hook these straight in if we can.
|
||||
// import { WindowsService as VSWindowsService } from "vs/platform/windows/electron-main/windowsService";
|
||||
// import { WindowsManager } from "vs/code/electron-main/windows";
|
||||
import { client } from "../client";
|
||||
|
||||
/**
|
||||
* Instead of going to the shared process, we'll directly run these methods on
|
||||
@ -199,9 +196,8 @@ class WindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
// Shared process
|
||||
public whenSharedProcessReady(): Promise<void> {
|
||||
// TODO: Update once shared process is tied in.
|
||||
return Promise.resolve();
|
||||
public async whenSharedProcessReady(): Promise<void> {
|
||||
await client.sharedProcessData;
|
||||
}
|
||||
|
||||
public toggleSharedProcess(): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user