Commit fb9241fc authored by Volodymyr Yurchenko's avatar Volodymyr Yurchenko
Browse files

JAL-80 #comment Improve reading host and port from env

parent c01c6803
......@@ -21,6 +21,7 @@ struct lws_context_creation_info;
#include "TJAlienResult.h"
#include "TJAlienCredentials.h"
#include "TJAlienDNSResolver.h"
#include "TJClientFile.h"
#include "TError.h"
#include "TGrid.h"
......
......@@ -101,30 +101,25 @@ void TJAlienConnectionManager::clearFlags()
//______________________________________________________________________________
void TJAlienConnectionManager::ConnectJBox(TJAlienCredentialsObject c)
{
std::string jboxHost = "";
int jboxPort = 0;
// Try to load host and port env vars
std::string envHost = getenv("JALIEN_HOST");
int envPort = atoi(getenv("JALIEN_WSPORT"));
if (envHost != NULL && envHost.length() != 0 && envPort > 0) {
jboxHost = envHost;
jboxPort = envPort;
}
else {
std::string jboxHost = std::getenv("JALIEN_HOST") ? : "";
int jboxPort = std::getenv("JALIEN_WSPORT") ? atoi(std::getenv("JALIEN_WSPORT")) : 0;
if (jboxHost.length() == 0 || jboxPort == 0) {
// Try to find jclient_token file
TJClientFile jcf;
if (jcf.isValid) {
jboxHost = (std::string)jcf.fHost;
jboxHost = (std::string) jcf.fHost;
jboxPort = jcf.fWSPort;
}
else if (gDebug >= 1) Info("TJAlienConnectionManager", "The JClient file is not valid - not connecting to JBox!");
}
if (jboxHost.length() == 0 || envPort == 0) {
if (jboxHost.length() == 0 || jboxPort == 0) {
if (gDebug >= 1) Info("TJAlienConnectionManager", "Failed to find any local JBox endpoint");
return;
}
MakeWebsocketConnection(c, jboxHost, jboxPort);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment