Skip to content

Commit 321d6c4

Browse files
XPavwiktorn
authored andcommitted
Add check for OVERPASS_DIFF_URL in rules_loop.sh
1 parent 3621a3d commit 321d6c4

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

bin/rules_loop.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ pushd "$EXEC_DIR" || exit 1
3838

3939
while true; do
4040
{
41-
START=$(date +%s)
42-
echo "$(date '+%F %T'): update started" >>"$DB_DIR/rules_loop.log"
43-
./osm3s_query --progress --rules <"$DB_DIR/rules/areas.osm3s"
44-
echo "$(date '+%F %T'): update finished" >>"$DB_DIR/rules_loop.log"
45-
WORK_TIME=$(($(date +%s) - START))
46-
SLEEP_TIME=$((WORK_TIME * 100 / CPU_LOAD - WORK_TIME))
47-
# let SLEEP_TIME be at least 3 seconds
48-
SLEEP_TIME=$((SLEEP_TIME < 3 ? 3 : SLEEP_TIME))
49-
echo "It took $WORK_TIME to run the loop. Desired load is: ${CPU_LOAD}%. Sleeping: $SLEEP_TIME"
50-
sleep "$SLEEP_TIME"
41+
if [[ -z "${OVERPASS_DIFF_URL}" ]]; then
42+
echo "OVERPASS_DIFF_URL is not set - updates disabled, assuming areas created on init, sleeping forever"
43+
sleep infinity
44+
else
45+
START=$(date +%s)
46+
echo "$(date '+%F %T'): update started" >>"$DB_DIR/rules_loop.log"
47+
./osm3s_query --progress --rules <"$DB_DIR/rules/areas.osm3s"
48+
echo "$(date '+%F %T'): update finished" >>"$DB_DIR/rules_loop.log"
49+
WORK_TIME=$(($(date +%s) - START))
50+
SLEEP_TIME=$((WORK_TIME * 100 / CPU_LOAD - WORK_TIME))
51+
# let SLEEP_TIME be at least 3 seconds
52+
SLEEP_TIME=$((SLEEP_TIME < 3 ? 3 : SLEEP_TIME))
53+
echo "It took $WORK_TIME to run the loop. Desired load is: ${CPU_LOAD}%. Sleeping: $SLEEP_TIME"
54+
sleep "$SLEEP_TIME"
55+
fi
5156
}
5257
done

0 commit comments

Comments
 (0)