Skip to content

Commit 250a8a3

Browse files
committed
Fix imposm liveness
1 parent 5d6c7cb commit 250a8a3

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

images/tiler-imposm/liveness.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
DIFF_DIR="/mnt/data/diff"
44
STATE_FILE="$DIFF_DIR/last.state.txt"
55
MAX_STALE_SECONDS="${MAX_STALE_SECONDS:-3600}" # 1 hour
6+
READY_FILE="/tmp/imposm_ready"
7+
STARTUP_GRACE_SECONDS="${STARTUP_GRACE_SECONDS:-300}" # 5 minutes
8+
9+
# Skip checks if imposm hasn't started yet (still in startup/config phase)
10+
if [ ! -f "$READY_FILE" ]; then
11+
# Check how long the container has been running
12+
UPTIME_SECONDS=$(awk '{print int($1)}' /proc/uptime)
13+
if [ "$UPTIME_SECONDS" -lt "$STARTUP_GRACE_SECONDS" ]; then
14+
echo "Imposm still starting up (${UPTIME_SECONDS}s < ${STARTUP_GRACE_SECONDS}s grace). Skipping checks."
15+
exit 0
16+
else
17+
echo "Startup grace period exceeded and imposm never became ready. Exiting..."
18+
pkill -f start.sh && exit 1
19+
fi
20+
fi
621

722
# 1) Check if imposm is running
823
if ! pgrep -f imposm >/dev/null; then

images/tiler-imposm/start.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ if [ -s /tmp/imposm.log ]; then
2727
# Keep only the last 20 log files to avoid filling the volume
2828
ls -t "$IMPOSM_LOG_DIR"/imposm_*.log 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
2929
fi
30-
# Clear log to prevent liveness probe from detecting stale errors on restart
30+
# Clear log and ready flag to prevent liveness probe from detecting stale errors on restart
3131
> /tmp/imposm.log
32+
rm -f /tmp/imposm_ready
3233

3334
# Tracking file for uploaded files
3435
TRACKING_FILE="$WORKDIR/uploaded_files.log"
@@ -286,6 +287,9 @@ EOF
286287
-quiet 2>&1 | tee /tmp/imposm.log &
287288
IMPOSM_PID=$!
288289

290+
# Signal liveness probe that imposm is running
291+
touch /tmp/imposm_ready
292+
289293
# Step 5: Monitor imposm process and handle errors
290294
monitorImposmErrors $IMPOSM_PID $UPLOADER_PID
291295
}

0 commit comments

Comments
 (0)