From 1e9563d3f99c5ea695114395086e9ee4aedb8b5b Mon Sep 17 00:00:00 2001 From: Alex Pavloff Date: Thu, 5 Mar 2026 09:27:50 -0700 Subject: [PATCH] Add check for OVERPASS_DIFF_URL in rules_loop.sh --- bin/rules_loop.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/rules_loop.sh b/bin/rules_loop.sh index f2540b3..40c3640 100755 --- a/bin/rules_loop.sh +++ b/bin/rules_loop.sh @@ -38,15 +38,20 @@ pushd "$EXEC_DIR" || exit 1 while true; do { - START=$(date +%s) - echo "$(date '+%F %T'): update started" >>"$DB_DIR/rules_loop.log" - ./osm3s_query --progress --rules <"$DB_DIR/rules/areas.osm3s" - echo "$(date '+%F %T'): update finished" >>"$DB_DIR/rules_loop.log" - WORK_TIME=$(($(date +%s) - START)) - SLEEP_TIME=$((WORK_TIME * 100 / CPU_LOAD - WORK_TIME)) - # let SLEEP_TIME be at least 3 seconds - SLEEP_TIME=$((SLEEP_TIME < 3 ? 3 : SLEEP_TIME)) - echo "It took $WORK_TIME to run the loop. Desired load is: ${CPU_LOAD}%. Sleeping: $SLEEP_TIME" - sleep "$SLEEP_TIME" + if [[ -z "${OVERPASS_DIFF_URL}" ]]; then + echo "OVERPASS_DIFF_URL is not set - updates disabled, assuming areas created on init, sleeping forever" + sleep infinity + else + START=$(date +%s) + echo "$(date '+%F %T'): update started" >>"$DB_DIR/rules_loop.log" + ./osm3s_query --progress --rules <"$DB_DIR/rules/areas.osm3s" + echo "$(date '+%F %T'): update finished" >>"$DB_DIR/rules_loop.log" + WORK_TIME=$(($(date +%s) - START)) + SLEEP_TIME=$((WORK_TIME * 100 / CPU_LOAD - WORK_TIME)) + # let SLEEP_TIME be at least 3 seconds + SLEEP_TIME=$((SLEEP_TIME < 3 ? 3 : SLEEP_TIME)) + echo "It took $WORK_TIME to run the loop. Desired load is: ${CPU_LOAD}%. Sleeping: $SLEEP_TIME" + sleep "$SLEEP_TIME" + fi } done