Skip to content

Separate process wrappers and pass arguments #2334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/node/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { coderCloudBind } from "./coder-cloud"
import { commit, version } from "./constants"
import { register } from "./routes"
import { humanPath, isFile, open } from "./util"
import { ipcMain, WrapperProcess } from "./wrapper"
import { isChild, wrapper } from "./wrapper"

export const runVsCodeCli = (args: DefaultedArgs): void => {
logger.debug("forking vs code cli...")
Expand Down Expand Up @@ -137,7 +137,7 @@ const main = async (args: DefaultedArgs): Promise<void> => {
logger.info(" - Connected to cloud agent")
} catch (err) {
logger.error(err.message)
ipcMain.exit(1)
wrapper.exit(1)
}
}

Expand All @@ -161,9 +161,9 @@ async function entry(): Promise<void> {
// There's no need to check flags like --help or to spawn in an existing
// instance for the child process because these would have already happened in
// the parent and the child wouldn't have been spawned.
if (ipcMain.isChild) {
await ipcMain.handshake()
ipcMain.preventExit()
if (isChild(wrapper)) {
await wrapper.handshake()
wrapper.preventExit()
return main(args)
}

Expand Down Expand Up @@ -201,11 +201,10 @@ async function entry(): Promise<void> {
return openInExistingInstance(args, socketPath)
}

const wrapper = new WrapperProcess(require("../../package.json").version)
return wrapper.start()
}

entry().catch((error) => {
logger.error(error.message)
ipcMain.exit(error)
wrapper.exit(error)
})
4 changes: 2 additions & 2 deletions src/node/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { rootPath } from "./constants"
import { settings } from "./settings"
import { SocketProxyProvider } from "./socket"
import { isFile } from "./util"
import { ipcMain } from "./wrapper"
import { wrapper } from "./wrapper"

export class VscodeProvider {
public readonly serverRootPath: string
Expand All @@ -20,7 +20,7 @@ export class VscodeProvider {
public constructor() {
this.vsRootPath = path.resolve(rootPath, "lib/vscode")
this.serverRootPath = path.join(this.vsRootPath, "out/vs/server")
ipcMain.onDispose(() => this.dispose())
wrapper.onDispose(() => this.dispose())
}

public async dispose(): Promise<void> {
Expand Down
Loading