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
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
Prev Previous commit
Remove unused wrapper options
Also move our memory default to the beginning of NODE_OPTIONS so it can
be overidden. The version of the flag with dashes seems to be the more
correct one now so use that instead of underscores.

Related: #2113.
  • Loading branch information
code-asher committed Nov 18, 2020
commit 95ef6dbf2f9eaf999406878d195e3318721c1f3c
15 changes: 2 additions & 13 deletions src/node/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ class ChildProcess extends Process {
}
}

export interface WrapperOptions {
maxMemory?: number
nodeOptions?: string
}

/**
* Parent process wrapper that spawns the child process and performs a handshake
* with it. Will relaunch the child if it receives a SIGUSR1 or is asked to by
Expand All @@ -224,7 +219,7 @@ export class ParentProcess extends Process {

private args?: DefaultedArgs

public constructor(private currentVersion: string, private readonly options?: WrapperOptions) {
public constructor(private currentVersion: string) {
super()

process.on("SIGUSR1", async () => {
Expand Down Expand Up @@ -310,18 +305,12 @@ export class ParentProcess extends Process {
}

private spawn(): cp.ChildProcess {
// Flags to pass along to the Node binary.
let nodeOptions = `${process.env.NODE_OPTIONS || ""} ${(this.options && this.options.nodeOptions) || ""}`
if (!/max_old_space_size=(\d+)/g.exec(nodeOptions)) {
nodeOptions += ` --max_old_space_size=${(this.options && this.options.maxMemory) || 2048}`
}

// Use spawn (instead of fork) to use the new binary in case it was updated.
return cp.spawn(process.argv[0], process.argv.slice(1), {
env: {
...process.env,
CODE_SERVER_PARENT_PID: process.pid.toString(),
NODE_OPTIONS: nodeOptions,
NODE_OPTIONS: `--max-old-space-size=2048 ${process.env.NODE_OPTIONS || ""}`,
},
stdio: ["ipc"],
})
Expand Down