From addd5a79cf8486dbee7689d30d5beb66e2c08763 Mon Sep 17 00:00:00 2001 From: Christopher Poenaru Date: Mon, 26 Jun 2017 21:46:11 -0400 Subject: [PATCH] Fixing cache_expiration script and updating to trex 0.7.5 --- resources/tileserver/Dockerfile | 20 +++++++++++++++++--- resources/tileserver/cache_expiry.py | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/resources/tileserver/Dockerfile b/resources/tileserver/Dockerfile index 56b7446..11bb59c 100644 --- a/resources/tileserver/Dockerfile +++ b/resources/tileserver/Dockerfile @@ -1,12 +1,26 @@ FROM ubuntu:16.04 RUN apt-get update -RUN apt-get install -y wget +RUN apt-get install -y wget python +RUN apt-get update +RUN apt-get install -y python-pip + +RUN pip install -U psycopg2 WORKDIR /opt/t-rex -RUN wget https://github.com/pka/t-rex/releases/download/v0.7.2/t-rex-v0.7.2-x86_64-unknown-linux-gnu.tar.gz && tar xvf t-rex* +RUN wget https://github.com/pka/t-rex/releases/download/v0.7.5/t-rex-v0.7.5-x86_64-unknown-linux-gnu.tar.gz && tar xvf t-rex* +ADD cache_expiry.py cache-expiry.py ADD config.toml config.toml -CMD ["/opt/t-rex/t_rex", "serve", "--config=/opt/t-rex/config.toml"] +# Write start script to start the expiration service and tileserver together +RUN echo """#!/bin/bash \n \ + python /opt/t-rex/cache-expiry.py >> cache_expiration.log & \ + ./t_rex serve --config=/opt/t-rex/config.toml""" >> /start.sh +RUN chmod +x /start.sh + +# Expose the tileserver port +EXPOSE 8080 + +CMD ["/start.sh"] diff --git a/resources/tileserver/cache_expiry.py b/resources/tileserver/cache_expiry.py index ebbb8b9..04ac7d5 100644 --- a/resources/tileserver/cache_expiry.py +++ b/resources/tileserver/cache_expiry.py @@ -22,7 +22,7 @@ timestamp = row[1] if bound is not None: print 'Rendering tiles for bounding box ' + str(bound) - cmd = 'trex --config=/config.toml --extent=' + str(bound) + ' --ignore_cache=true --minzoom=0 --maxzoom=17' + cmd = 'cd /opt/t-rex && ./t_rex generate --config=/config.toml --extent=' + str(bound) + ' --overwrite=true --minzoom=0 --maxzoom=17' FNULL = open(os.devnull, 'w') subprocess.call(cmd, shell=True, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True) cur.execute("UPDATE tile_cache_expirations SET processed_at = now() where created_at = (%s)", [timestamp])