use of ru.yandex.qatools.embed.postgresql.PostgresProcess in project gradle-postgresql-embedded by honourednihilist.
the class EmbeddedPostgres method start.
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();
}
Aggregations