From a02daac96111c465cdcf54e19408888bd8da8858 Mon Sep 17 00:00:00 2001 From: Steffen Volkmann Date: Tue, 16 Apr 2019 07:45:10 +0200 Subject: [PATCH] environment variable AUTOVACUUM added The postgressql autovacuum feature is by default active. The environment variable AUTOVACUUM allows you to switch off this feature during start of docker container. --- Dockerfile | 5 +++-- README.md | 8 ++++++++ postgresql.custom.conf => postgresql.custom.conf.tmpl | 0 run.sh | 11 +++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) rename postgresql.custom.conf => postgresql.custom.conf.tmpl (100%) diff --git a/Dockerfile b/Dockerfile index 51b205e..10dab0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ FROM ubuntu:18.04 # Set up environment ENV TZ=UTC +ENV AUTOVACUUM=on RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Install dependencies @@ -135,9 +136,9 @@ RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \ && ln -sf /proc/1/fd/2 /var/log/apache2/error.log # Configure PosgtreSQL -COPY postgresql.custom.conf /etc/postgresql/10/main/ +COPY postgresql.custom.conf.tmpl /etc/postgresql/10/main/ RUN chown -R postgres:postgres /var/lib/postgresql \ - && chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf \ + && chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf.tmpl \ && echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/10/main/postgresql.conf # Start running diff --git a/README.md b/README.md index 97618f2..3ead79a 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,18 @@ Tiles that have already been rendered will be stored in `/var/lib/mod_tile`. To ## Performance tuning +### THREADS + The import and tile serving processes use 4 threads by default, but this number can be changed by setting the `THREADS` environment variable. For example: docker run -p 80:80 -e THREADS=24 -v openstreetmap-data:/var/lib/postgresql/10/main -d overv/openstreetmap-tile-server run +### AUTOVACUUM + +The database use the autovacuum feature by default. This behavior can be changed with `AUTOVACUUM` environment variable. For example: + + docker run -p 80:80 -e AUTOVACUUM=off -v openstreetmap-data:/var/lib/postgresql/10/main -d overv/openstreetmap-tile-server + ## License ``` diff --git a/postgresql.custom.conf b/postgresql.custom.conf.tmpl similarity index 100% rename from postgresql.custom.conf rename to postgresql.custom.conf.tmpl diff --git a/run.sh b/run.sh index 701d33e..d7c0d01 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,14 @@ #!/bin/bash +set -x + +function CreatePostgressqlConfig() +{ + cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/postgresql.custom.conf + sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/10/main/postgresql.custom.conf + cat /etc/postgresql/10/main/postgresql.custom.conf +} + if [ "$#" -ne 1 ]; then echo "usage: " echo "commands:" @@ -12,6 +21,7 @@ fi if [ "$1" = "import" ]; then # Initialize PostgreSQL + CreatePostgressqlConfig service postgresql start sudo -u postgres createuser renderer sudo -u postgres createdb -E UTF8 -O renderer gis @@ -35,6 +45,7 @@ fi if [ "$1" = "run" ]; then # Initialize PostgreSQL and Apache + CreatePostgressqlConfig service postgresql start service apache2 restart