Skip to content

Commit 1817631

Browse files
committed
Switch to metatile based expiry on render servers
1 parent 50c5e66 commit 1817631

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

cookbooks/tile/templates/default/expire-tiles.erb

+45-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,53 @@
22

33
# DO NOT EDIT - This file is being maintained by Chef
44

5-
args = [
6-
"--socket=/var/run/renderd/renderd.sock",
7-
"--tile-dir=/srv/tile.openstreetmap.org/tiles",
8-
"--touch-from=13",
9-
"--min-zoom=13"
5+
require "fileutils"
6+
7+
tileDirs = [
8+
<% node[:tile][:styles].each_key do |name| -%>
9+
"/srv/tile.openstreetmap.org/tiles/<%= name %>",
10+
<% end -%>
1011
]
1112
13+
tilesExpired = 0
14+
tilesIgnored = 0
15+
16+
expiredTime = Time.new(2000, 1, 1)
17+
1218
Dir.glob("/var/lib/replicate/expire-queue/changes-*.txt").sort.each do |f|
13-
<% node[:tile][:styles].each do |name,details| -%>
14-
system("/usr/bin/render_expired", "--map=<%= name %>", *args, "--max-zoom=<%= details[:max_zoom] %>", :in=> f) &&
15-
<% end -%>
19+
File.open(f, "r") do |file|
20+
file.each do |line|
21+
z, y, x = line.split("/")
22+
23+
z = z.to_i + 3
24+
y = y.to_i * 8
25+
x = x.to_i * 8
26+
27+
hash = []
28+
29+
1.upto(5) do
30+
hash.push(((x & 0xf) << 4) | (y & 0xf))
31+
32+
x = x >> 4
33+
y = y >> 4
34+
end
35+
36+
tileName = "#{z}/#{hash[4]}/#{hash[3]}/#{hash[2]}/#{hash[1]}/#{hash[0]}.meta"
37+
38+
tileDirs.each do |tileDir|
39+
if File.exist?("#{tileDir}/#{tileName}")
40+
FileUtils.touch("#{tileDir}/#{tileName}", :mtime => expiredTime)
41+
42+
tilesExpired = tilesExpired + 1
43+
else
44+
tilesIgnored = tilesIgnored + 1
45+
end
46+
end
47+
end
48+
end
49+
1650
File::unlink(f)
1751
end
52+
53+
puts "Meta tiles expired: #{tilesExpired}"
54+
puts "Meta tiles not present: #{tilesIgnored}"

cookbooks/tile/templates/default/replicate.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ do
1010
-- \
1111
--number-processes=1 \
1212
--log-progress=false \
13-
--expire-tiles=13-19 \
13+
--expire-tiles=10-16 \
1414
--expire-segment-length=90000 \
1515
--expire-output=/var/lib/replicate/dirty-tiles.txt \
1616
<% if node[:tile][:database][:multi_geometry] -%>

0 commit comments

Comments
 (0)