Skip to content

Commit

Permalink
NativeTorProcess: Remove log file monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Apr 15, 2024
1 parent a6980b3 commit 2a66d72
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@

package bisq.tor.process;

import bisq.common.FileCreationWatcher;
import bisq.common.scanner.FileScanner;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

@Slf4j
public class NativeTorProcess {
Expand All @@ -41,7 +35,6 @@ public class NativeTorProcess {
private final Path torBinaryPath;
private final Path torrcPath;
private Optional<Process> process = Optional.empty();
private Optional<Future<Path>> logFileCreationWaiter = Optional.empty();

public NativeTorProcess(Path torDataDirPath) {
this.torDataDirPath = torDataDirPath;
Expand All @@ -66,8 +59,6 @@ public void start() {
processBuilder.redirectError(ProcessBuilder.Redirect.DISCARD);
processBuilder.redirectOutput(ProcessBuilder.Redirect.DISCARD);

logFileCreationWaiter = Optional.of(createLogFileCreationWaiter());

try {
Process torProcess = processBuilder.start();
process = Optional.of(torProcess);
Expand All @@ -76,24 +67,6 @@ public void start() {
}
}

public void waitUntilControlPortReady() {
try {
if (logFileCreationWaiter.isPresent()) {
Future<Path> pathFuture = logFileCreationWaiter.get();

FileScanner fileScanner = new FileScanner(
Set.of("[notice] Opened Control listener connection (ready) on "),
pathFuture
);
fileScanner.waitUntilLogContainsLines();
}

} catch (ExecutionException | IOException | InterruptedException | TimeoutException e) {
log.error("Couldn't wait for log file creation.", e);
throw new IllegalStateException("Couldn't wait for log file creation.");
}
}

public void waitUntilExited() {
log.info("Wait until tor process has exited");
process.ifPresent(process -> {
Expand All @@ -119,13 +92,4 @@ private void createTorControlDirectory() {
}
}
}

private Future<Path> createLogFileCreationWaiter() {
Path dataDir = torrcPath.getParent();
Path logFilePath = torrcPath.getParent().resolve("debug.log");

FileCreationWatcher fileCreationWatcher = new FileCreationWatcher(dataDir);
return fileCreationWatcher.waitForFile(logFilePath);
}

}

0 comments on commit 2a66d72

Please sign in to comment.