瀏覽代碼

set psql application_name in startup script

Grant Limberg 3 年之前
父節點
當前提交
dc61f78916
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 1 1
      controller/PostgreSQL.cpp
  2. 3 1
      ext/central-controller-docker/main.sh

+ 1 - 1
controller/PostgreSQL.cpp

@@ -150,7 +150,7 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
 {
 	char myAddress[64];
 	_myAddressStr = myId.address().toString(myAddress);
-	_connString = std::string(path) + " application_name=controller_" + _myAddressStr;
+	_connString = std::string(path);
 	auto f = std::make_shared<PostgresConnFactory>(_connString);
 	_pool = std::make_shared<ConnectionPool<PostgresConnection> >(
 		15, 5, std::static_pointer_cast<ConnectionFactory>(f));

+ 3 - 1
ext/central-controller-docker/main.sh

@@ -62,9 +62,11 @@ popd
 
 DEFAULT_PORT=9993
 
+APP_NAME="controller-$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f 1)"
+
 echo "{
     \"settings\": {
-        \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\",
+        \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\",
         \"portMappingEnabled\": true,
         \"softwareUpdate\": \"disable\",
         \"interfacePrefixBlacklist\": [