Skip to content

Commit

Permalink
Merge pull request #148 from MarcMil/allow-access-process
Browse files Browse the repository at this point in the history
Allow to access the postgress process directly
  • Loading branch information
tomix26 authored Feb 6, 2025
2 parents ed189ed + c332e5e commit 4c3dde5
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class EmbeddedPostgres implements Closeable

private final ProcessBuilder.Redirect errorRedirector;
private final ProcessBuilder.Redirect outputRedirector;
private final Process process;

EmbeddedPostgres(File parentDirectory, File dataDirectory, boolean cleanDataDirectory,
Map<String, String> postgresConfig, Map<String, String> localeConfig, int port, Map<String, String> connectConfig,
Expand Down Expand Up @@ -158,7 +159,11 @@ public class EmbeddedPostgres implements Closeable
}

lock();
startPostmaster();
this.process = startPostmaster();
}

public Process getProcess() {
return this.process;
}

public DataSource getTemplateDatabase()
Expand Down Expand Up @@ -251,7 +256,7 @@ private void initdb()
LOG.info("{} initdb completed in {}", instanceId, watch);
}

private void startPostmaster() throws IOException
private Process startPostmaster() throws IOException
{
final StopWatch watch = new StopWatch();
watch.start();
Expand Down Expand Up @@ -283,6 +288,7 @@ private void startPostmaster() throws IOException
Runtime.getRuntime().addShutdownHook(newCloserThread());

waitForServerStartup(watch);
return postmaster;
}

private List<String> createInitOptions()
Expand Down

0 comments on commit 4c3dde5

Please sign in to comment.