Skip to content

Commit

Permalink
add more context to the error message when the index creation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ltclm committed Dec 10, 2024
1 parent 8dda133 commit af64b2e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/pg2sphinx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ docker_is_logged_in() {
docker pull "${DOCKER_IMG_LOCAL_TAG}" &> /dev/null
}

throw_error() {
error=$1
echo "index generation failed"
echo "the docker command was: ${DOCKER_EXEC}"
free -m
docker stats --no-stream
echo "original error code: ${error}"
exit "${error}"
}

# check if we have read-write access to the efs
if ! /bin/test -d "${SPHINX_EFS}" -a -w "${SPHINX_EFS}"; then
>&2 echo "no read-write access to folder ${SPHINX_EFS} available"
Expand All @@ -21,12 +31,12 @@ fi

if [ -n "${DB:-}" ]; then
# call pg2sphinx trigger with DATABASE pattern
${DOCKER_EXEC} python3 pg2sphinx_trigger.py -s /etc/sphinxsearch/sphinx.conf -c update -d "${DB}"
${DOCKER_EXEC} python3 pg2sphinx_trigger.py -s /etc/sphinxsearch/sphinx.conf -c update -d "${DB}" || { throw_error $?; }
fi

if [ -n "${INDEX:-}" ]; then
# call pg2sphinx trigger with INDEX pattern
${DOCKER_EXEC} python3 pg2sphinx_trigger.py -s /etc/sphinxsearch/sphinx.conf -c update -i "${INDEX}"
${DOCKER_EXEC} python3 pg2sphinx_trigger.py -s /etc/sphinxsearch/sphinx.conf -c update -i "${INDEX}" || { throw_error $?; }
fi

mapfile -t array_config < <(${DOCKER_EXEC} cat /etc/sphinxsearch/sphinx.conf | grep -E "^[^#]+ path" | awk -F"=" '{print $2}' | sed -n 's|^.*/||p' | sed 's/\r$//')
Expand Down

0 comments on commit af64b2e

Please sign in to comment.