Skip to content

Suggestion: optional executable path #48

@joaisa17

Description

@joaisa17

On my dedicated server build, I occasionally need to run multiple versions of Java at the same time. To run the latest version of java, this library does the job, but when I want to run java8 for modded servers, I need to specify where the java executible is.

I would suggest adding a executable option, with the default value of java to the javaserver config, and then implementing it in the start function.

Current

export class JavaServer extends EventsEmitter {
  // ...
  public start() {
    if (this.process) {
      throw new Error('JavaServer already running');
    }

    this.process = spawn('java', [...this.config.javaServer.args, '-jar', this.config.javaServer.jar, 'nogui'], {
      cwd: this.config.javaServer.path,
      stdio: ['pipe', 'pipe', 'pipe'],
    });
    //...
  }
}

Suggested

export class JavaServer extends EventsEmitter {
  // ...
  public start() {
    if (this.process) {
      throw new Error('JavaServer already running');
    }

    this.process = spawn(this.config.javaServer.executable, [...this.config.javaServer.args, '-jar', this.config.javaServer.jar, 'nogui'], {
      cwd: this.config.javaServer.path,
      stdio: ['pipe', 'pipe', 'pipe'],
    });
    //...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions