poststartup script moved to extra container, non init

This commit is contained in:
Leo Sok 2025-07-24 13:43:11 +03:00
parent eb3ccd30e7
commit d23a46f828

View File

@ -179,7 +179,7 @@ extraContainers:
- /bin/bash
- -c
- |
set -ex
set -ex
echo "[template-loader] Waiting for Elasticsearch at $ES_URL..."
for i in $(seq 1 ${MAX_RETRIES:-30}); do
if curl -s "$ES_URL" >/dev/null; then
@ -189,16 +189,22 @@ extraContainers:
echo "[template-loader] Attempt $i: ES not ready, sleeping..."
sleep "${RETRY_INTERVAL:-5}"
done
echo "[template-loader] Applying index templates..."
echo "[template-loader] Checking and applying index templates if needed..."
for idx in "chat:$TEMPLATE_PATH_1" "message:$TEMPLATE_PATH_2" "user:$TEMPLATE_PATH_3"; do
name="${idx%%:*}"
path="${idx##*:}"
echo "[template-loader] Applying template: $name from $path..."
curl -X PUT "$ES_URL/$name" \
-H 'Content-Type: application/json' \
--data-binary @"$path"
# Check if index exists
if curl -sf -o /dev/null "$ES_URL/$name"; then
echo "[template-loader] Index $name already exists. Skipping."
else
echo "[template-loader] Creating index $name from $path..."
curl -X PUT "$ES_URL/$name" \
-H 'Content-Type: application/json' \
--data-binary @"$path"
fi
done
echo "[template-loader] All templates applied. Exiting."
echo "[template-loader] All templates applied (or skipped). Exiting."
env:
- name: ES_URL
value: "http://elasticsearch-master:9200"