From d8e098d2d3fdfe6425fcbc9d31a56591e3d771de Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Fri, 25 Jun 2021 13:03:05 +0200 Subject: [PATCH 1/5] promote GET error if Vector Tile cannot be fetched --- src/serve_rendered.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 11b6bfb00..5b92be8f5 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -641,25 +641,30 @@ module.exports = { const parts = url.parse(req.url); const extension = path.extname(parts.pathname).toLowerCase(); const format = extensionToFormat[extension] || ''; - if (err || res.statusCode < 200 || res.statusCode >= 300) { + // send empty response with status code 500 if vector tile server errors + if (res.statusCode >= 500) { + console.log('HTTP error when fetching vector tile', err || res.statusCode); + return false; + } + else if (err || res.statusCode < 200 || res.statusCode >= 300) { // console.log('HTTP error', err || res.statusCode); createEmptyResponse(format, '', callback); return; - } + } else { + const response = {}; + if (res.headers.modified) { + response.modified = new Date(res.headers.modified); + } + if (res.headers.expires) { + response.expires = new Date(res.headers.expires); + } + if (res.headers.etag) { + response.etag = res.headers.etag; + } - const response = {}; - if (res.headers.modified) { - response.modified = new Date(res.headers.modified); - } - if (res.headers.expires) { - response.expires = new Date(res.headers.expires); - } - if (res.headers.etag) { - response.etag = res.headers.etag; + response.data = body; + callback(null, response); } - - response.data = body; - callback(null, response); }); } } From b91fd03806951531eb3fd8fdd124630b63c238fa Mon Sep 17 00:00:00 2001 From: zstadler Date: Tue, 2 Feb 2021 12:35:19 +0200 Subject: [PATCH 2/5] Document configuration reloading when using docker Based on https://github.com/maptiler/tileserver-gl/issues/420#issuecomment-766332814 --- docs/usage.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/usage.rst b/docs/usage.rst index d96da38b2..9d74b8614 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -33,4 +33,8 @@ Reloading configuration ====== It is possible to reload the configuration file without restarting the whole process by sending a SIGHUP signal to the node process. -However, this does not currently work when running the tileserver-gl docker container (the signal is not passed to the subprocess, see https://github.com/maptiler/tileserver-gl/issues/420#issuecomment-597507663). + +When running the tileserver-gl docker container, the signal must be sent from within the container: +:: + + docker exec tileserver-gl bash -c 'kill -HUP $(ls -l /proc/*/exe | sed -n "/\/node$/s/.*proc\/\([0-9]\+\)\/exe .*/\1/p")' From b5a3db8d0e533e45c180534541364b7b979af33b Mon Sep 17 00:00:00 2001 From: zstadler Date: Wed, 22 Dec 2021 18:38:44 +0200 Subject: [PATCH 3/5] Simplify reloading the configuration with docker Allow `docker kill -s HUP` and `docker-compose kill -s HUP` to reach the node process. --- docker-entrypoint.sh | 8 ++++++++ docs/usage.rst | 8 +++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8b7984c28..538d25393 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -10,6 +10,14 @@ handle() { trap handle INT TERM +refresh() { + SIGNAL=$(( $? - 128 )) + echo "Caught signal ${SIGNAL}, refreshing" + kill -s ${SIGNAL} $(pidof node) 2>/dev/null +} + +trap refresh HUP + if ! which -- "${1}"; then # first arg is not an executable xvfb-run -a --server-args="-screen 0 1024x768x24" -- node /app/ "$@" & diff --git a/docs/usage.rst b/docs/usage.rst index 9d74b8614..b688c47e5 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -29,12 +29,10 @@ Default preview style and configuration - If no configuration file is specified, a default preview style (compatible with openmaptiles) is used. - If no mbtiles file is specified (and is not found in the current working directory), a sample file is downloaded (showing the Zurich area) -Reloading configuration +Reloading the configuration ====== It is possible to reload the configuration file without restarting the whole process by sending a SIGHUP signal to the node process. -When running the tileserver-gl docker container, the signal must be sent from within the container: -:: - - docker exec tileserver-gl bash -c 'kill -HUP $(ls -l /proc/*/exe | sed -n "/\/node$/s/.*proc\/\([0-9]\+\)\/exe .*/\1/p")' +- The `docker kill -s HUP tileserver-gl` command can be used when running the tileserver-gl docker container. +- The `docker-compose -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service. From 61422912ecebc774b6d7d5f1596d0adcbe45da9b Mon Sep 17 00:00:00 2001 From: zstadler Date: Sat, 5 Mar 2022 22:37:39 +0200 Subject: [PATCH 4/5] Update usage.rst Typo correction --- docs/usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.rst b/docs/usage.rst index b688c47e5..127af2df3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -35,4 +35,4 @@ Reloading the configuration It is possible to reload the configuration file without restarting the whole process by sending a SIGHUP signal to the node process. - The `docker kill -s HUP tileserver-gl` command can be used when running the tileserver-gl docker container. -- The `docker-compose -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service. +- The `docker-compose kill -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service. From 582b52985e3b9f0abdaf52ab6ed32d772c1d3a6e Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 6 Mar 2022 16:33:56 +0200 Subject: [PATCH 5/5] Allow multiple refreshes by sending multiple `HUP` kill commands to the container. --- docker-entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 538d25393..a93e296da 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -24,6 +24,10 @@ if ! which -- "${1}"; then # Wait exits immediately on signals which have traps set. Store return value and wait # again for all jobs to actually complete before continuing. wait $! || RETVAL=$? + while [ ${RETVAL} = 129 ] ; do + # Refressh signal HUP received. Continue waiting for signals. + wait $! || RETVAL=$? + done wait exit ${RETVAL} fi