mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-02 16:52:49 +00:00
finish the RabbitMQ-ectomy
This commit is contained in:
parent
c9f942f79b
commit
15c0c1db39
@ -128,8 +128,10 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
|
|||||||
opts.db = 0;
|
opts.db = 0;
|
||||||
poolOpts.size = 10;
|
poolOpts.size = 10;
|
||||||
if (_rc->clusterMode) {
|
if (_rc->clusterMode) {
|
||||||
|
fprintf(stderr, "Using Redis in Cluster Mode\n");
|
||||||
_cluster = std::make_shared<sw::redis::RedisCluster>(opts, poolOpts);
|
_cluster = std::make_shared<sw::redis::RedisCluster>(opts, poolOpts);
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(stderr, "Using Redis in Standalone Mode\n");
|
||||||
_redis = std::make_shared<sw::redis::Redis>(opts, poolOpts);
|
_redis = std::make_shared<sw::redis::Redis>(opts, poolOpts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,7 +615,7 @@ void PostgreSQL::heartbeat()
|
|||||||
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(OSUtils::now());
|
||||||
std::string host_port = std::to_string(_listenPort);
|
std::string host_port = std::to_string(_listenPort);
|
||||||
std::string use_rabbitmq = (false) ? "true" : "false";
|
std::string use_redis = (_rc != NULL) ? "true" : "false";
|
||||||
const char *values[10] = {
|
const char *values[10] = {
|
||||||
controllerId,
|
controllerId,
|
||||||
hostname,
|
hostname,
|
||||||
@ -624,16 +626,16 @@ void PostgreSQL::heartbeat()
|
|||||||
rev.c_str(),
|
rev.c_str(),
|
||||||
build.c_str(),
|
build.c_str(),
|
||||||
host_port.c_str(),
|
host_port.c_str(),
|
||||||
use_rabbitmq.c_str()
|
use_redis.c_str()
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *res = PQexecParams(conn,
|
PGresult *res = PQexecParams(conn,
|
||||||
"INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, v_rev, v_build, host_port, use_rabbitmq) "
|
"INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, v_rev, v_build, host_port, use_rabbitmq, use_redis) "
|
||||||
"VALUES ($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6, $7, $8, $9, $10) "
|
"VALUES ($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6, $7, $8, $9, $10, $11) "
|
||||||
"ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = EXCLUDED.last_alive, "
|
"ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = EXCLUDED.last_alive, "
|
||||||
"public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = EXCLUDED.v_minor, "
|
"public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = EXCLUDED.v_minor, "
|
||||||
"v_rev = EXCLUDED.v_rev, v_build = EXCLUDED.v_rev, host_port = EXCLUDED.host_port, "
|
"v_rev = EXCLUDED.v_rev, v_build = EXCLUDED.v_rev, host_port = EXCLUDED.host_port, "
|
||||||
"use_rabbitmq = EXCLUDED.use_rabbitmq",
|
"use_redis = EXCLUDED.use_redis",
|
||||||
10, // number of parameters
|
10, // number of parameters
|
||||||
NULL, // oid field. ignore
|
NULL, // oid field. ignore
|
||||||
values, // values for substitution
|
values, // values for substitution
|
||||||
|
@ -37,7 +37,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$ZT_REDIS_CLUSTER_MODE" ];
|
if [ -z "$ZT_REDIS_CLUSTER_MODE" ]; then
|
||||||
echo '*** FAILED: ZT_REDIS_CLUSTER_MODE environment variable not defined'
|
echo '*** FAILED: ZT_REDIS_CLUSTER_MODE environment variable not defined'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -49,6 +49,8 @@ if [ "$ZT_USE_REDIS" == "true" ]; then
|
|||||||
\"password\": \"${ZT_REDIS_PASSWORD}\"
|
\"password\": \"${ZT_REDIS_PASSWORD}\"
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
else
|
||||||
|
REDIS="\"redis\": {}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /var/lib/zerotier-one
|
mkdir -p /var/lib/zerotier-one
|
||||||
|
Loading…
x
Reference in New Issue
Block a user