Skip to content

Commit 6982447

Browse files
authored
Merge pull request #525 from geoadmin/feature_BGDIINF_SB-2530_readiness_probe
BGDIINF_SB-2530: add a first draft of readiness probe
2 parents f6887ad + 20b24de commit 6982447

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

scripts/checker.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,21 @@ set -e
33
set -u
44
set -o pipefail
55

6-
# Do the lifeness check exit status 0 -> success | 1 -> fail
7-
searchd --status 1> /dev/null && exit 0 || exit 1
6+
# mountpoint with readiness probe file
7+
MOUNT=$(realpath "${PROBE_MOUNTPOINT:-/tmp}")
8+
READY_FILE="${MOUNT}/checker_ready.txt"
9+
10+
clean_probe_files() {
11+
rm -f "${READY_FILE}" || :
12+
}
13+
14+
# source this stuff until here
15+
[ "$0" = "${BASH_SOURCE[*]}" ] || return 0
16+
17+
if searchd --status 1> /dev/null; then
18+
echo "READY" > "${READY_FILE}"
19+
exit 0
20+
else
21+
clean_probe_files
22+
exit 1
23+
fi

scripts/docker-cmd.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
2+
# shellcheck disable=SC1091
23
set -euo pipefail
34

5+
source checker.sh
6+
7+
# Capture Exit Code
8+
trap clean_probe_files EXIT
9+
410
# fancy output
511
green='\e[0;32m'
612
red='\e[0;31m'
@@ -22,7 +28,7 @@ for index in "${array_orphaned[@]}"; do
2228
[[ -z ${index} ]] && continue
2329
# skip .new files, we need them to sighup searchd / rotate index updates
2430
if [[ ! $index == *.new ]]; then
25-
echo -e "\t${red} deleting orphaned index ${index} from filesystem. ${NC}"
31+
echo -e "\\t${red} deleting orphaned index ${index} from filesystem. ${NC}"
2632
rm -rf "${SPHINXINDEX_EFS}${index}".*
2733
fi
2834
done

scripts/docker-entry.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash
2+
# shellcheck disable=SC1091
23
set -euo pipefail
34

5+
source checker.sh
6+
# geodata has to have rw access on probe mountpoint
7+
chown -R geodata:geodata "${MOUNT}"
8+
49
# build sphinx config with current environment
510
cat conf/*.part > conf/sphinx.conf.in
611
envsubst < conf/sphinx.conf.in > conf/sphinx.conf
@@ -12,4 +17,4 @@ cp -f conf/wordforms_main.txt /etc/sphinxsearch/wordforms_main.txt
1217
# always remove lock files from mounted shared storage
1318
rm -rf /var/lib/sphinxsearch/data/index/*.spl 2> /dev/null || :
1419

15-
exec gosu geodata "$@"
20+
exec gosu geodata "$@"

0 commit comments

Comments
 (0)