diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d943ad49dac130c814e2344cf635a7ea8788f58..1a3407acce0e6dd22163d75449cea99db91569f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ deploy_development: script: - export TAG=dev - export PROXY_MVT_BIND_PORT=9003 - - export ELASTICSEARCH_URL=https://kong-dev.alpha.grandlyon.com/es-consumer-aware + - export ELASTICSEARCH_URL=https://data-reloaded-dev.alpha.grandlyon.com/api/es-consumer-aware - export TECHNICAL_ACCOUNT_USERNAME=$TECHNICAL_ACCOUNT_USERNAME - export TECHNICAL_ACCOUNT_PASSWORD=$TECHNICAL_ACCOUNT_PASSWORD - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY @@ -51,13 +51,14 @@ deploy_staging: script: - export TAG=staging - export PROXY_MVT_BIND_PORT=9103 - - export ELASTICSEARCH_URL=https://kong-rec.alpha.grandlyon.com/es-consumer-aware + - export ELASTICSEARCH_URL=https://data-reloaded-rec.alpha.grandlyon.com/api/es-consumer-aware - export TECHNICAL_ACCOUNT_USERNAME=$TECHNICAL_ACCOUNT_USERNAME - export TECHNICAL_ACCOUNT_PASSWORD=$TECHNICAL_ACCOUNT_PASSWORD - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - TAG=dev docker-compose pull - - docker tag $CI_REGISTRY/refonte-data/proxy-map-services:dev $CI_REGISTRY/refonte-data/proxy-map-services:${TAG} - - docker push $CI_REGISTRY/refonte-data/proxy-map-services:${TAG} + - export REGISTRY_PATH=web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/proxies/web-mapping-services + - docker tag $CI_REGISTRY/$REGISTRY_PATH:dev $CI_REGISTRY/$REGISTRY_PATH:${TAG} + - docker push $CI_REGISTRY/$REGISTRY_PATH:${TAG} - docker-compose --project-name proxy-map-services-${TAG} up -d --force-recreate environment: name: staging diff --git a/Dockerfile b/Dockerfile index 9f816a58108abb2c55139f3cd2d53528929e30cc..8734e3172be3990e022329347601551962a471ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 0, based on Node.js, to build and compile Angular -FROM node:8.10.0 +FROM node:12.13-slim # Copy the package.json file first in order to cache the modules COPY ./package.json /app/package.json diff --git a/docker-compose.yml b/docker-compose.yml index a74a8da97f48a85245513a3214bb53bf362f4492..1dfabb4f7d8ff169475497538e4e6e26e1890fba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: proxy-mvt: restart: unless-stopped build: . - image: registry.alpha.grandlyon.com/refonte-data/proxy-map-services:${TAG} + image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/proxies/web-mapping-services:${TAG} ports: - ${PROXY_MVT_BIND_PORT}:9000 environment: @@ -19,6 +19,7 @@ services: - PROXY_HOST_TARGET=${PROXY_HOST_TARGET} depends_on: - redis-sentinel-1 + restart: unless-stopped redis-master: image: 'bitnami/redis:latest' @@ -26,6 +27,7 @@ services: - ALLOW_EMPTY_PASSWORD=yes volumes: - redis-master:/bitnami/redis/data + restart: unless-stopped redis-sentinel-1: image: 'bitnami/redis-sentinel:latest' @@ -34,6 +36,7 @@ services: - REDIS_MASTER_SET=mymaster volumes: - redis-sentinel-1:/bitnami/redis/data + restart: unless-stopped redis-slave-1: image: 'bitnami/redis:latest' @@ -42,6 +45,7 @@ services: - ALLOW_EMPTY_PASSWORD=yes volumes: - redis-slave-1:/bitnami/redis/data + restart: unless-stopped volumes: redis-master: diff --git a/index.js b/index.js index e62d65ac60e78c9396f0f17a1514919069e0155f..f74241309399ea7c5c32484ae81f11638b7b6672 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,43 @@ var mvtUnauthProxy = httpProxy.createProxyServer({ target: proxyHostTarget, }); +// keep a referece of the proxyRequest in the req object +wmsProxy.on('proxyReq', function (proxyReq, req) { + req._proxyReq = proxyReq; +}); + +mvtProxy.on('proxyReq', function (proxyReq, req) { + req._proxyReq = proxyReq; +}); + +mvtUnauthProxy.on('proxyReq', function (proxyReq, req) { + req._proxyReq = proxyReq; +}); + +wmsProxy.on('error', function (err, req, res) { + // If the client cancelled the request, abort the request to the upstream server + if (req.socket.destroyed && err.code === 'ECONNRESET') { + req._proxyReq.abort(); + } + return console.log(`WMS Error, req.socket.destroyed: ${req.socket.destroyed}, ${err}`); +}); + +mvtProxy.on('error', function (err, req, res) { + // If the client cancelled the request, abort the request to the upstream server + if (req.socket.destroyed && err.code === 'ECONNRESET') { + req._proxyReq.abort(); + } + return console.log(`MVT Error, req.socket.destroyed: ${req.socket.destroyed}, ${err}`); +}); + +mvtUnauthProxy.on('error', function (err, req, res) { + // If the client cancelled the request, abort the request to the upstream server + if (req.socket.destroyed && err.code === 'ECONNRESET') { + req._proxyReq.abort(); + } + return console.log(`MVT Unauthenticated Error, req.socket.destroyed: ${req.socket.destroyed}, ${err}`); +}); + // Create an HTTP server http.createServer(async function (req, res) { diff --git a/package.json b/package.json index abc297133a07473b9b088b3d4bd6d4fbf85ba2ea..5678cc999a6ea4910c233c9154cfbf9c0282bcb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "proxy-map-services", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "index.js", "scripts": {