Skip to content

Commit 20e7cd8

Browse files
Jozef Volakmarosmars
Jozef Volak
authored andcommitted
Uniconfig DB pools based on replicas
1 parent 88ee5d6 commit 20e7cd8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

generate_uc_compose.sh

+19
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ function prepareConfigFiles {
267267
}
268268

269269

270+
function computeDbPools {
271+
if [[ ${__UC_INSTANCES} -eq 1 ]]; then
272+
DB_POOLS=300;
273+
UC_POOLS=300;
274+
elif [[ ${__UC_INSTANCES} -eq 2 ]]; then
275+
DB_POOLS=300;
276+
UC_POOLS=150;
277+
else
278+
DB_POOLS=$((${__UC_INSTANCES} * 100));
279+
UC_POOLS=100;
280+
fi
281+
}
282+
283+
270284
function generateUcCompose {
271285

272286
if [[ "${__SERVICE_NAME}" == "uniconfig" ]]; then
@@ -313,6 +327,10 @@ function generateUcCompose {
313327
# networks
314328
sed -i 's|uniconfig-network|'"${__SERVICE_NAME}-network|g" "${__COMPOSE_PATH}"
315329

330+
# db pools
331+
sed -i 's|maxDbPoolSize=300|'"maxDbPoolSize=${UC_POOLS}|g" "${__COMPOSE_PATH}"
332+
sed -i 's|max_connections=300|'"max_connections=${DB_POOLS}|g" "${__COMPOSE_PATH}"
333+
316334
}
317335

318336
function prepareFolder {
@@ -350,4 +368,5 @@ __UNICONFIG_SERVICE_SUFIX="uniconfig-controller"
350368
argumentsCheck "$@"
351369
isNodeInSwarm ${__NODE_ID}
352370
prepareFolder
371+
computeDbPools
353372
generateUcCompose

0 commit comments

Comments
 (0)