32 lines
1.2 KiB
Bash
Executable File
32 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# --------------------------------------------------------------------------
|
|
# check_routing_sync.sh
|
|
# Runs via cron every minute to check if the admin dashboard requested
|
|
# a routing graph rebuild (due to a newly approved road).
|
|
# --------------------------------------------------------------------------
|
|
|
|
APP_DIR="/home/hamzadoctor/app"
|
|
cd "${APP_DIR}"
|
|
|
|
# Read flag from Redis using the redis container
|
|
SYNC_REQ=$(docker compose exec -T redis redis-cli get routing_sync_requested | tr -d '\r')
|
|
|
|
if [ "$SYNC_REQ" = "1" ] || [ "$SYNC_REQ" = "\"1\"" ]; then
|
|
echo "$(date): Sync requested! Triggering delta apply and GH rebuild..."
|
|
|
|
# 1. Delete the flag immediately so we don't trigger it again
|
|
docker compose exec -T redis redis-cli del routing_sync_requested
|
|
|
|
# 2. Apply delta
|
|
if [ -f "${APP_DIR}/infrastructure/scripts/apply-delta.sh" ]; then
|
|
bash "${APP_DIR}/infrastructure/scripts/apply-delta.sh"
|
|
fi
|
|
|
|
# 3. Restart GraphHopper to rebuild index
|
|
docker compose stop routing
|
|
rm -rf "${APP_DIR}/infrastructure/osm-data/graph-cache" "${APP_DIR}/infrastructure/osm-data/default-gh"
|
|
docker compose up -d routing
|
|
|
|
echo "$(date): Routing rebuild triggered successfully."
|
|
fi
|