Added early exit for unreachable Ollama
build / build (push) Has been cancelled

This commit is contained in:
2026-05-28 13:06:37 +02:00
parent ff45efbe67
commit b3cb4d86b6
@@ -401,6 +401,32 @@ public class Core {
}));
}
/**
* A check to exit early if Ollama isn't reachable.
*/
private void confirmOllama()
{
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
connection.setConnectTimeout(3 * 1000);
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
new RuntimeException("Ollama is un-responsive on url: " + url.toString()).printStackTrace();
System.exit(1);
}
}catch (IOException ex)
{
ex.printStackTrace();
System.out.println("Can not reach Ollama!");
System.exit(1);
}
}
/**
* Creates a new instance of Core with the provided PrintMessageHandler,
* defaulting the Ollama backend to {@code localhost}.
@@ -425,6 +451,7 @@ public class Core {
initDirectories();
initOllamaUrl();
confirmOllama();
initLogWriter();
initScheduler();
initShutdownHook();