Skip to content

Commit

Permalink
pid fetch changed
Browse files Browse the repository at this point in the history
142: Cached server path fails to find PID on Unix

Task-Url: yandex-qatools#142
  • Loading branch information
miwroblewski committed Sep 25, 2018
1 parent d0a65e6 commit dc600ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
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

0 comments on commit dc600ec

Please sign in to comment.