2 # -*- coding: utf-8 -*-
11 # HTML Debug of errors
14 # Limit maximum CPU time
15 # The Postscript output format can sometimes take hours
16 resource.setrlimit(resource.RLIMIT_CPU,(180,180))
19 # Some odd requests can cause extreme memory usage
20 resource.setrlimit(resource.RLIMIT_AS,(4000000000, 4000000000))
22 # Routine to output HTTP headers
23 def output_headers(content_type, filename = "", length = 0):
24 print "Cache-Control: no-cache, no-store, must-revalidate')"
25 print "Pragma: no-cache"
27 print "Content-Type: %s" % content_type
29 print "Content-Disposition: attachment; filename=\"%s\"" % filename
31 print "Content-Length: %d" % length
34 # Routine to report an error
35 def output_error(message):
36 output_headers("text/html")
39 print "<title>Error</title>"
42 print "<h1>Error</h1>"
43 print "<p>%s</p>" % message
47 # Make sure we have a user agent
48 if not os.environ.has_key('HTTP_USER_AGENT'):
49 os.environ['HTTP_USER_AGENT'] = 'NONE'
51 # Get the load average
52 loadavg = float(open("/proc/loadavg").readline().split(" ")[0])
54 output_headers("text/html")
57 print "<title>tile.openstreetmap.org debug</title>"
60 print "<h1>tile.openstreetmap.org debug</h1>"
61 print "<h2>Server Stats</h2>"
63 print "<b>Render Server</b>: <%= node['fqdn'] %><br />"
64 print "<b>Load Average</b>: %s</p>" % loadavg
65 print "<h2>File Status</h2>"
68 node[:tile][:data].each do |name,data|
70 file = "/srv/tile.openstreetmap.org/data/#{File.basename(url)}"
71 file_basename = File.basename(url)
73 print "<b>%s</b> last modified: %s<br />" % ("<%= file_basename %>", time.ctime(os.path.getmtime("<%= file %>")))
78 print "<h2>Browser Request Headers</h2>"
80 for param in os.environ.keys():
81 print "<b>%20s</b>: %s<br />" % (param, os.environ[param])