Skip to content

Commit

Permalink
Uniconfig DB pools based on replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Volak authored and marosmars committed Sep 19, 2022
1 parent 88ee5d6 commit 20e7cd8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions generate_uc_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ function prepareConfigFiles {
}


function computeDbPools {
if [[ ${__UC_INSTANCES} -eq 1 ]]; then
DB_POOLS=300;
UC_POOLS=300;
elif [[ ${__UC_INSTANCES} -eq 2 ]]; then
DB_POOLS=300;
UC_POOLS=150;
else
DB_POOLS=$((${__UC_INSTANCES} * 100));
UC_POOLS=100;
fi
}


function generateUcCompose {

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

# db pools
sed -i 's|maxDbPoolSize=300|'"maxDbPoolSize=${UC_POOLS}|g" "${__COMPOSE_PATH}"
sed -i 's|max_connections=300|'"max_connections=${DB_POOLS}|g" "${__COMPOSE_PATH}"

}

function prepareFolder {
Expand Down Expand Up @@ -350,4 +368,5 @@ __UNICONFIG_SERVICE_SUFIX="uniconfig-controller"
argumentsCheck "$@"
isNodeInSwarm ${__NODE_ID}
prepareFolder
computeDbPools
generateUcCompose

0 comments on commit 20e7cd8

Please sign in to comment.