Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Goblint server mode #19

Merged
merged 14 commits into from
Feb 28, 2022
Merged
21 changes: 16 additions & 5 deletions src/main/java/goblintserver/GoblintServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.concurrent.TimeoutException;
import java.util.stream.Stream;
import java.io.*;
import java.nio.file.*;

import com.google.gson.*;

Expand Down Expand Up @@ -64,13 +65,23 @@ public boolean startGoblintServer() {
return false;
}

while(!goblintSocket.exists()) {
Thread.sleep(1000);
// wait until Goblint socket is created before continuing
WatchService watchService = FileSystems.getDefault().newWatchService();
Path path = Paths.get(System.getProperty("user.dir"));
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE );
WatchKey key;
while ((key = watchService.take()) != null) {
for (WatchEvent<?> event : key.pollEvents()) {
if (event.context().toString().equals(goblintSocket.toString())) {
karoliineh marked this conversation as resolved.
Show resolved Hide resolved
log.info("Goblint server started.");
return true;
}
}
key.reset();
}

log.info("Goblint server started.");

return true;
return false;

} catch (IOException | InvalidExitValueException | InterruptedException | TimeoutException e) {
this.magpieServer.forwardMessageToClient(new MessageParams(MessageType.Error, "Running Goblint failed. " + e.getMessage()));
return false;
Expand Down