tileserver: added /check route for healthchecks

This commit is contained in:
Jenny Danzmayr 2023-07-14 05:30:54 +02:00
parent 3650da72d3
commit 743d48b796

View file

@ -172,6 +172,14 @@ class TileServer:
('ETag', etag)]) ('ETag', etag)])
return [data] return [data]
def check_response(self, start_response):
self.get_cache_package()
text = b'OK'
start_response('200 OK', [self.get_date_header(),
('Content-Type', 'text/plain'),
('Content-Length', str(len(text)))])
return [text]
def get_cache_package(self): def get_cache_package(self):
try: try:
cache_package_filename = self.cache.get('cache_package_filename') cache_package_filename = self.cache.get('cache_package_filename')
@ -199,6 +207,10 @@ class TileServer:
def __call__(self, env, start_response): def __call__(self, env, start_response):
path_info = env['PATH_INFO'] path_info = env['PATH_INFO']
if path_info == '/check':
return self.check_response(start_response)
match = self.path_regex.match(path_info) match = self.path_regex.match(path_info)
if match is None: if match is None:
return self.not_found(start_response, b'invalid tile path.') return self.not_found(start_response, b'invalid tile path.')