Routing build status: show the container's step while a request is queued; Apply during a build of the same regions queues nothing
CI / check (push) Successful in 20s
CI / deploy (push) Successful in 22s

This commit is contained in:
randy committed 2026-11-14 00:20:02 +01:00
1 parent 59447c56f2
commit 92efe118b0
2 files changed
+23 -1

No files matched your search

+7 -1
View File
@@ -44,6 +44,10 @@ module Maptool
missing = codes.reject { |code| File.exist?(extract_path(data_dir, code)) }
raise PmtilesBuilder::BuildError, "no downloaded map data for #{missing.join(", ")}, build the offline map first" if missing.any?
# Apply again while the same countries are building: nothing to queue.
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"
write_json(File.join(dir(data_dir), "build-request.json"), regions: codes, requested_at: Time.now.utc.iso8601)
end
end
@@ -59,9 +63,11 @@ module Maptool
# started_at, message.
def self.build_status(data_dir)
return { state: "running", step: "waiting for the offline map build" } if MUTEX.synchronize { @pending }
status = read_json(File.join(dir(data_dir), "status.json"))
return status if status&.dig(:state) == "running" # the container is building; a queued request runs next
return { state: "running", step: "waiting for the routing container" } if File.exist?(File.join(dir(data_dir), "build-request.json"))
read_json(File.join(dir(data_dir), "status.json")) || { state: "idle" }
status || { state: "idle" }
end
# The DataFileRow status shape, plus whether Valhalla answers.