Skip to content

Commit

Permalink
Merge pull request #525 from geoadmin/feature_BGDIINF_SB-2530_readine…
Browse files Browse the repository at this point in the history
…ss_probe

BGDIINF_SB-2530: add a first draft of readiness probe
  • Loading branch information
ltclm authored Sep 7, 2022
2 parents f6887ad + 20b24de commit 6982447
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
20 changes: 18 additions & 2 deletions scripts/checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,21 @@ set -e
set -u
set -o pipefail

# Do the lifeness check exit status 0 -> success | 1 -> fail
searchd --status 1> /dev/null && exit 0 || exit 1
# mountpoint with readiness probe file
MOUNT=$(realpath "${PROBE_MOUNTPOINT:-/tmp}")
READY_FILE="${MOUNT}/checker_ready.txt"

clean_probe_files() {
rm -f "${READY_FILE}" || :
}

# source this stuff until here
[ "$0" = "${BASH_SOURCE[*]}" ] || return 0

if searchd --status 1> /dev/null; then
echo "READY" > "${READY_FILE}"
exit 0
else
clean_probe_files
exit 1
fi
8 changes: 7 additions & 1 deletion scripts/docker-cmd.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
# shellcheck disable=SC1091
set -euo pipefail

source checker.sh

# Capture Exit Code
trap clean_probe_files EXIT

# fancy output
green='\e[0;32m'
red='\e[0;31m'
Expand All @@ -22,7 +28,7 @@ for index in "${array_orphaned[@]}"; do
[[ -z ${index} ]] && continue
# skip .new files, we need them to sighup searchd / rotate index updates
if [[ ! $index == *.new ]]; then
echo -e "\t${red} deleting orphaned index ${index} from filesystem. ${NC}"
echo -e "\\t${red} deleting orphaned index ${index} from filesystem. ${NC}"
rm -rf "${SPHINXINDEX_EFS}${index}".*
fi
done
Expand Down
7 changes: 6 additions & 1 deletion scripts/docker-entry.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
# shellcheck disable=SC1091
set -euo pipefail

source checker.sh
# geodata has to have rw access on probe mountpoint
chown -R geodata:geodata "${MOUNT}"

# build sphinx config with current environment
cat conf/*.part > conf/sphinx.conf.in
envsubst < conf/sphinx.conf.in > conf/sphinx.conf
Expand All @@ -12,4 +17,4 @@ cp -f conf/wordforms_main.txt /etc/sphinxsearch/wordforms_main.txt
# always remove lock files from mounted shared storage
rm -rf /var/lib/sphinxsearch/data/index/*.spl 2> /dev/null || :

exec gosu geodata "$@"
exec gosu geodata "$@"

0 comments on commit 6982447

Please sign in to comment.