Skip to content

Commit 4c3dde5

Browse files
authored
Merge pull request #148 from MarcMil/allow-access-process
Allow to access the postgress process directly
2 parents ed189ed + c332e5e commit 4c3dde5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/io/zonky/test/db/postgres/embedded/EmbeddedPostgres.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public class EmbeddedPostgres implements Closeable
108108

109109
private final ProcessBuilder.Redirect errorRedirector;
110110
private final ProcessBuilder.Redirect outputRedirector;
111+
private final Process process;
111112

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

160161
lock();
161-
startPostmaster();
162+
this.process = startPostmaster();
163+
}
164+
165+
public Process getProcess() {
166+
return this.process;
162167
}
163168

164169
public DataSource getTemplateDatabase()
@@ -251,7 +256,7 @@ private void initdb()
251256
LOG.info("{} initdb completed in {}", instanceId, watch);
252257
}
253258

254-
private void startPostmaster() throws IOException
259+
private Process startPostmaster() throws IOException
255260
{
256261
final StopWatch watch = new StopWatch();
257262
watch.start();
@@ -283,6 +288,7 @@ private void startPostmaster() throws IOException
283288
Runtime.getRuntime().addShutdownHook(newCloserThread());
284289

285290
waitForServerStartup(watch);
291+
return postmaster;
286292
}
287293

288294
private List<String> createInitOptions()

0 commit comments

Comments
 (0)