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

pid fetch changed #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,9 @@ protected void deleteTempFiles() {
@Override
protected final void onAfterProcessStart(ProcessControl process,
IRuntimeConfig runtimeConfig) throws IOException {
final Storage storage = getConfig().storage();
final Path pidFilePath = Paths.get(storage.dbDir().getAbsolutePath(), "postmaster.pid");
final File pidFile = new File(pidFilePath.toAbsolutePath().toString());
int timeout = TIMEOUT;
while (!pidFile.exists() && ((timeout = timeout - 100) > 0)) {
try {
sleep(100);
} catch (InterruptedException ie) { /* safe to ignore */ }
}
int pid = -1;
try {
pid = Integer.valueOf(readLines(pidFilePath.toFile()).get(0));
} catch (Exception e) {
LOGGER.error("Failed to read PID file ({})", e.getMessage(), e);
}
if (pid != -1) {
setProcessId(pid);
} else {
// fallback, try to read pid file. will throw IOException if that fails
setProcessId(getPidFromFile(pidFile()));
}

final Storage storage = getConfig().storage();
setProcessId(process.getPid());

int trial = 0;
do {
String output = runCmd(getConfig(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static IRuntimeConfig runtimeConfig(Command cmd) {

public static <E extends AbstractPGExecutable<PostgresConfig, P>, P extends AbstractPGProcess<E, P>>
PostgresStarter<E, P> getCommand(Command command, IRuntimeConfig config) {
return new PostgresStarter<>(command.executableClass(), config);
return new PostgresStarter<E,P>(command.executableClass(), config);
}

public static <E extends AbstractPGExecutable<PostgresConfig, P>, P extends AbstractPGProcess<E, P>>
Expand Down