-
Notifications
You must be signed in to change notification settings - Fork 15
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
HPC: Ensure load balancer finds hq when located in same directory #59
Comments
Would it be fine to implement a function that checks for the existence of this binary in PATH and expands for execution? proof of concept below (excluding any checks for whether this binary is executable): #include <cstdlib>
#include <iostream>
#include <string>
#include <filesystem>
#include <vector>
std::string findBinary() {
std::vector<std::string> pathsToCheck;
// Check in PATH
if (const char* env_p = std::getenv("PATH")) {
std::string pathEnv = env_p;
std::string delimiter = ":";
size_t pos = 0;
while ((pos = pathEnv.find(delimiter)) != std::string::npos) {
pathsToCheck.push_back(pathEnv.substr(0, pos));
pathEnv.erase(0, pos + delimiter.length());
}
pathsToCheck.push_back(pathEnv);
}
// Also check current directory
pathsToCheck.push_back(".");
for (const auto& path : pathsToCheck) {
std::filesystem::path fullPath = path + "/hq";
if (std::filesystem::exists(fullPath) && std::filesystem::is_regular_file(fullPath)) {
return fullPath;
}
}
throw std::runtime_error("Error: 'hq' binary not found in PATH or current directory.");
}
int main() {
std::string hqBinaryPath;
try {
hqBinaryPath = findBinary();
std::cout << "Found hq binary at: " << hqBinaryPath << std::endl;
} catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
} |
I wonder if a hq installation outside the load balancer directory is realistic, so maybe we should just directly call ./hq ? |
Quickly fixed by recent commit. Additionally checking for hq binary as in #67 would be nicer though |
Currently needs PATH variable to be extended by location of hq
The text was updated successfully, but these errors were encountered: