Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.
This repository was archived by the owner on May 12, 2020. It is now read-only.

Problem brining postgres up on windows 7 using version 1.15 #37

Open
@scottmf

Description

@scottmf

There is a problem with the args which are used in the ProcessBuilder which causes postgres not to launch properly on windows with no errors or any output indicating an issue. Subsequently createdb.exe fails its 3 attempts. This problem occurs using Command.PgCtl as well as Postgres. I tried this on two windows 7 systems (32 and 64 bit) both fail with this same problem. On 'nix systems it works fine.

The issue is the "-o "-p " "-h 127.0.0.1"" is not properly inserted into the args of RuntimeBuilder. The args need to be added separately

args.add("-o");
args.add("-p -h 127.0.0.1");

Here is a snippet of my workaround:

private void start() {
        IRuntimeConfig config = new RuntimeConfigBuilder().defaults(Command.PgCtl)
                 // rewrite args using ICommandLinePostProcessor
                .commandLinePostProcessor(new CommandLinePostProcessor(net.port()))
                .build();
}

private static class CommandLinePostProcessor implements ICommandLinePostProcessor {
    private int port;
    public CommandLinePostProcessor(int port) {
        this.port = port;
    }

    @Override
    public List<String> process(Distribution distribution, List<String> args) {
        String command = args.get(0);
        if (!command.contains("pg_ctl")) {
            return args;
        }
        String datadir = args.get(3);
        args.clear();
        args.add(command);
        args.add(format("-o"));
        // this is the issue, rewriting fixes the problem
        args.add(format("-p %s -h 127.0.0.1", port));
        args.add("-D");
        args.add(datadir);
        args.add("-w");
        stopArgs = new ArrayList<String>(args);
        args.add("start");
        return args;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions