diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8b7984c28..a93e296da 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -10,12 +10,24 @@ 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/ "$@" & # 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 diff --git a/docs/usage.rst b/docs/usage.rst index d96da38b2..127af2df3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -29,8 +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. -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). + +- The `docker kill -s HUP tileserver-gl` command can be used when running the tileserver-gl docker container. +- The `docker-compose kill -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service. 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); }); } }