diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 505d76527..286a734e0 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -128,8 +128,10 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R opts.db = 0; poolOpts.size = 10; if (_rc->clusterMode) { + fprintf(stderr, "Using Redis in Cluster Mode\n"); _cluster = std::make_shared(opts, poolOpts); } else { + fprintf(stderr, "Using Redis in Standalone Mode\n"); _redis = std::make_shared(opts, poolOpts); } } @@ -613,7 +615,7 @@ void PostgreSQL::heartbeat() std::string build = std::to_string(ZEROTIER_ONE_VERSION_BUILD); std::string now = std::to_string(OSUtils::now()); 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] = { controllerId, hostname, @@ -624,16 +626,16 @@ void PostgreSQL::heartbeat() rev.c_str(), build.c_str(), host_port.c_str(), - use_rabbitmq.c_str() + use_redis.c_str() }; 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) " - "VALUES ($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6, $7, $8, $9, $10) " + "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, $11) " "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, " "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 NULL, // oid field. ignore values, // values for substitution diff --git a/ext/central-controller-docker/main.sh b/ext/central-controller-docker/main.sh index 6f6a01f69..e0ebabae0 100755 --- a/ext/central-controller-docker/main.sh +++ b/ext/central-controller-docker/main.sh @@ -37,7 +37,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then exit 1 fi - if [ -z "$ZT_REDIS_CLUSTER_MODE" ]; + if [ -z "$ZT_REDIS_CLUSTER_MODE" ]; then echo '*** FAILED: ZT_REDIS_CLUSTER_MODE environment variable not defined' exit 1 fi @@ -49,6 +49,8 @@ if [ "$ZT_USE_REDIS" == "true" ]; then \"password\": \"${ZT_REDIS_PASSWORD}\" } " +else + REDIS="\"redis\": {}" fi mkdir -p /var/lib/zerotier-one