@ -696,6 +696,15 @@ are_files_locked_in_dir() {
export -f are_files_locked_in_dir
export -f are_files_locked_in_dir
set_db_params() {
local docker_ip="$1" docker_network="$2"
if [ -z "$DB_PARAMS_LOADED" ]; then
DB_PARAMS_LOADED=1
_set_db_params "$docker_ip" "$docker_network"
fi
}
export -f set_db_params
export _PID="$$"
export _PID="$$"
ensure_db_docker_running () {
ensure_db_docker_running () {
local _STATE_FILE
local _STATE_FILE
@ -706,7 +715,7 @@ ensure_db_docker_running () {
IFS=: read DOCKER_NETWORK DOCKER_IP <<<"$(cat "$_STATE_FILE")"
IFS=: read DOCKER_NETWORK DOCKER_IP <<<"$(cat "$_STATE_FILE")"
debug "Re-using previous docker/connection '$DOCKER_IP'."
debug "Re-using previous docker/connection '$DOCKER_IP'."
_ set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
return 0
return 0
fi
fi
@ -753,7 +762,7 @@ ensure_db_docker_running () {
docker pull "$DOCKER_BASE_IMAGE"
docker pull "$DOCKER_BASE_IMAGE"
fi
fi
_set_server_db_params
_set_server_db_params || return 1
debug docker network create "$_DB_NAME"
debug docker network create "$_DB_NAME"
if ! network_id=$(docker network create "$_DB_NAME"); then
if ! network_id=$(docker network create "$_DB_NAME"); then
err "'docker network create $_DB_NAME' failed !"
err "'docker network create $_DB_NAME' failed !"
@ -788,7 +797,7 @@ ensure_db_docker_running () {
echo "$docker_ip" > "$_STATE_FILE"
echo "$docker_ip" > "$_STATE_FILE"
debug "written '$_STATE_FILE'"
debug "written '$_STATE_FILE'"
rm "$state_tmpdir/${_DB_NAME}.working"
rm "$state_tmpdir/${_DB_NAME}.working"
_ set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
return 0
return 0
else
else
errlvl="$?"
errlvl="$?"
@ -923,7 +932,7 @@ wait_for_docker_ip() {
err "internal 'wait_docker_ip' did not return a valid IP. Returned IP is '$DOCKER_IP'."
err "internal 'wait_docker_ip' did not return a valid IP. Returned IP is '$DOCKER_IP'."
return 1
return 1
fi
fi
_ set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
while read-0 port; do
while read-0 port; do
IFS="/" read port type <<<"$port"
IFS="/" read port type <<<"$port"
[ "$type" == "tcp" ] || continue
[ "$type" == "tcp" ] || continue