private PostgresArtifactStoreBuilder storeBuilder() { return new PostgresArtifactStoreBuilder(); }
/** * Initializes the default runtime configuration using the temporary directory. * * @return runtime configuration required for postgres to start. */ public static IRuntimeConfig defaultRuntimeConfig() { return new RuntimeConfigBuilder() .defaults(Command.Postgres) .artifactStore(new PostgresArtifactStoreBuilder() .defaults(Command.Postgres) .download(new PostgresDownloadConfigBuilder() .defaultsForCommand(Command.Postgres) .build())) .commandLinePostProcessor(privilegedWindowsRunasPostprocessor()) .build(); }
/** * Initializes runtime configuration for cached directory. * If a provided directory is empty, postgres will be extracted into it. * * @param cachedPath path where postgres is supposed to be extracted * @return runtime configuration required for postgres to start */ public static IRuntimeConfig cachedRuntimeConfig(Path cachedPath) { final Command cmd = Command.Postgres; final FixedPath cachedDir = new FixedPath(cachedPath.toString()); return new RuntimeConfigBuilder() .defaults(cmd) .artifactStore(new PostgresArtifactStoreBuilder() .defaults(cmd) .tempDir(cachedDir) .download(new PostgresDownloadConfigBuilder() .defaultsForCommand(cmd) .packageResolver(new PackagePaths(cmd, cachedDir)) .build())) .commandLinePostProcessor(privilegedWindowsRunasPostprocessor()) .build(); }
public synchronized void start() throws IOException { if (process != null) { throw new IllegalStateException(); } Command command = Command.Postgres; IDownloadConfig downloadConfig = new PostgresDownloadConfigBuilder() .defaultsForCommand(command) .artifactStorePath(new FixedPath(artifactStorePath)) .build(); ArtifactStoreBuilder artifactStoreBuilder = new PostgresArtifactStoreBuilder() .defaults(command) .download(downloadConfig); LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor("started", new HashSet<>(singletonList("failed")), new Slf4jStreamProcessor(getLogger("postgres"), Slf4jLevel.TRACE)); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() .defaults(command) .processOutput(new ProcessOutput(logWatch, logWatch, logWatch)) .artifactStore(artifactStoreBuilder) .build(); PostgresStarter<PostgresExecutable, PostgresProcess> starter = new PostgresStarter<>(PostgresExecutable.class, runtimeConfig); PostgresConfig config = new PostgresConfig(version, new AbstractPostgresConfig.Net(host, port == 0 ? Network.getFreeServerPort() : port), new AbstractPostgresConfig.Storage(dbName), new AbstractPostgresConfig.Timeout(), new AbstractPostgresConfig.Credentials(username, password)); process = starter.prepare(config).start(); jdbcUrl = "jdbc:postgresql://" + config.net().host() + ":" + config.net().port() + "/" + config.storage().dbName(); }
LOGGER.warn("Could not use the configured artifact store for '" + cmd.commandName() + "', falling back to default!"); artifactStore = new PostgresArtifactStoreBuilder().defaults(cmd).download(downloadCfg).build();