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