get a running controller in docker

This commit is contained in:
Grant Limberg 2025-09-04 11:42:53 -07:00
parent 686653509a
commit f33e706887
3 changed files with 4 additions and 33 deletions

View file

@ -164,10 +164,4 @@ fi
export GLIBCXX_FORCE_NEW=1
export GLIBCPP_FORCE_NEW=1
export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2"
#exec
/usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one
if [ $? -ne 0 ]; then
echo '*** FAILED: zerotier-one exited unexpectedly'
cat /var/lib/zerotier-one/local.conf
exit 1
fi
exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one

View file

@ -42,12 +42,6 @@
using json = nlohmann::json;
namespace {
static const int DB_MINIMUM_VERSION = 38;
} // anonymous namespace
using namespace ZeroTier;
using Attrs = std::vector<std::pair<std::string, std::string> >;
@ -88,7 +82,7 @@ CentralDB::CentralDB(
char myAddress[64];
_myAddressStr = myId.address().toString(myAddress);
_connString = std::string(connString);
fprintf(stderr, "connstring: %s\n", _connString.c_str());
auto f = std::make_shared<PostgresConnFactory>(_connString);
_pool =
std::make_shared<ConnectionPool<PostgresConnection> >(15, 5, std::static_pointer_cast<ConnectionFactory>(f));
@ -110,23 +104,6 @@ CentralDB::CentralDB(
fprintf(stderr, "Using redis for member status\n");
}
auto c = _pool->borrow();
pqxx::work txn { *c->c };
pqxx::row r { txn.exec1("SELECT version FROM ztc_database") };
int dbVersion = r[0].as<int>();
txn.commit();
if (dbVersion < DB_MINIMUM_VERSION) {
fprintf(
stderr,
"Central database schema version too low. This controller version requires a minimum schema version of "
"%d. Please upgrade your Central instance",
DB_MINIMUM_VERSION);
exit(1);
}
_pool->unborrow(c);
if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _cc->redisConfig != NULL) {
auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis");
auto innerscope = tracer->WithActiveSpan(innerspan);

View file

@ -655,7 +655,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender)
throw std::runtime_error("central controller requires postgres db");
}
const char* connString = _path.substr(9).c_str();
std::string connString = _path.substr(9);
CentralDB::ListenerMode lm;
if (_cc->listenMode == "pgsql") {
@ -685,7 +685,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender)
throw std::runtime_error("unsupported status mode");
}
_db.addDB(std::shared_ptr<CentralDB>(new CentralDB(_signingId, connString, _listenPort, lm, sm, _cc)));
_db.addDB(std::shared_ptr<CentralDB>(new CentralDB(_signingId, connString.c_str(), _listenPort, lm, sm, _cc)));
#else
#ifdef ZT_CONTROLLER_USE_LIBPQ
if ((_path.length() > 9) && (_path.substr(0, 9) == "postgres:")) {