check for running on machine before starting

This commit is contained in:
Jeff Raymakers
2025-03-09 10:59:38 -07:00
parent 62f9a73a57
commit 8c1f36c9cf
3 changed files with 29 additions and 0 deletions

View File

@@ -55,6 +55,22 @@ void HttpServer::UpdateDatabaseInstance(
}
}
bool HttpServer::IsRunningOnMachine(ClientContext &context) {
if (Started()) {
return true;
}
const auto local_port = GetLocalPort(context);
auto local_url = StringUtil::Format("http://localhost:%d", local_port);
httplib::Client client(local_url);
auto result = client.Get("/info");
if (result) {
return true;
}
return false;
}
bool HttpServer::Started() {
return server_instance && server_instance->main_thread;
}