mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 22:32:22 +00:00
add online controller list in Redis
This commit is contained in:
parent
beedee4401
commit
39da360725
@ -686,12 +686,13 @@ void PostgreSQL::heartbeat()
|
|||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
exit(6);
|
exit(6);
|
||||||
}
|
}
|
||||||
|
int64_t ts = OSUtils::now();
|
||||||
if (conn) {
|
if (conn) {
|
||||||
std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR);
|
std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR);
|
||||||
std::string minor = std::to_string(ZEROTIER_ONE_VERSION_MINOR);
|
std::string minor = std::to_string(ZEROTIER_ONE_VERSION_MINOR);
|
||||||
std::string rev = std::to_string(ZEROTIER_ONE_VERSION_REVISION);
|
std::string rev = std::to_string(ZEROTIER_ONE_VERSION_REVISION);
|
||||||
std::string build = std::to_string(ZEROTIER_ONE_VERSION_BUILD);
|
std::string build = std::to_string(ZEROTIER_ONE_VERSION_BUILD);
|
||||||
std::string now = std::to_string(OSUtils::now());
|
std::string now = std::to_string(ts);
|
||||||
std::string host_port = std::to_string(_listenPort);
|
std::string host_port = std::to_string(_listenPort);
|
||||||
std::string use_redis = (_rc != NULL) ? "true" : "false";
|
std::string use_redis = (_rc != NULL) ? "true" : "false";
|
||||||
const char *values[10] = {
|
const char *values[10] = {
|
||||||
@ -726,6 +727,13 @@ void PostgreSQL::heartbeat()
|
|||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
}
|
}
|
||||||
|
if (_rc != NULL) {
|
||||||
|
if (_rc->clusterMode) {
|
||||||
|
_cluster->zadd("controllers", controllerId, ts);
|
||||||
|
} else {
|
||||||
|
_redis->zadd("controllers", controllerId, ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user