Routing: reject a pre-merge multi-country request, don't resume a failed build, Apply queues when the running build lacks the merge
This commit is contained in:
1 parent
acf5256c74
commit
dbe1804ebf
2 files changed
+7
-2
No files matched your search
@@ -62,6 +62,10 @@ build() {
|
|||||||
mv "$R/build-request.json" "$S/request.json"
|
mv "$R/build-request.json" "$S/request.json"
|
||||||
regions=$(python3 -c 'import json,sys; print(" ".join(json.load(open(sys.argv[1]))["regions"]))' "$S/request.json")
|
regions=$(python3 -c 'import json,sys; print(" ".join(json.load(open(sys.argv[1]))["regions"]))' "$S/request.json")
|
||||||
pbf=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("pbf", ""))' "$S/request.json")
|
pbf=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("pbf", ""))' "$S/request.json")
|
||||||
|
if [ -z "$pbf" ] && [ "$(echo $regions | wc -w)" -gt 1 ]; then # a request from before the merge
|
||||||
|
status error "" "this request has several countries but no merged extract; click Apply again"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
if [ -n "$pbf" ]; then # several countries, merged by maptool (Valhalla breaks on overlapping extracts)
|
if [ -n "$pbf" ]; then # several countries, merged by maptool (Valhalla breaks on overlapping extracts)
|
||||||
ln "/data/$pbf" "$R/pbf/" || { status error "" "missing $pbf"; return 1; }
|
ln "/data/$pbf" "$R/pbf/" || { status error "" "missing $pbf"; return 1; }
|
||||||
else
|
else
|
||||||
@@ -103,7 +107,8 @@ if [ -f "$S/request.json" ] && [ ! -f "$R/build-request.json" ]; then
|
|||||||
fi
|
fi
|
||||||
serve
|
serve
|
||||||
while true; do
|
while true; do
|
||||||
[ -f "$R/build-request.json" ] && build
|
# A failed build isn't retried by the next restart.
|
||||||
|
[ -f "$R/build-request.json" ] && { build || rm -f "$S/request.json"; }
|
||||||
# valhalla_service died (or never started): start it again.
|
# valhalla_service died (or never started): start it again.
|
||||||
if [ -n "$SERVICE_PID" ] && ! kill -0 "$SERVICE_PID" 2>/dev/null; then serve; fi
|
if [ -n "$SERVICE_PID" ] && ! kill -0 "$SERVICE_PID" 2>/dev/null; then serve; fi
|
||||||
sleep 10 & wait $! # interruptible, so the trap above runs right away
|
sleep 10 & wait $! # interruptible, so the trap above runs right away
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ module Maptool
|
|||||||
|
|
||||||
# Apply again while the same countries are building: nothing to queue.
|
# Apply again while the same countries are building: nothing to queue.
|
||||||
running = read_json(File.join(dir(data_dir), "staging", "request.json"))
|
running = read_json(File.join(dir(data_dir), "staging", "request.json"))
|
||||||
return if running && running[:regions] == codes && read_json(File.join(dir(data_dir), "status.json"))&.dig(:state) == "running"
|
return if running && running[:regions] == codes && running.key?(:pbf) == (codes.size > 1) && read_json(File.join(dir(data_dir), "status.json"))&.dig(:state) == "running"
|
||||||
|
|
||||||
return if @merging&.dig(:state) == "running"
|
return if @merging&.dig(:state) == "running"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user