Routing build status: show the container's step while a request is queued; Apply during a build of the same regions queues nothing
This commit is contained in:
1 parent
59447c56f2
commit
92efe118b0
2 files changed
+23
-1
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user