From 32f8f3803fa4d96dd8eac346938fb6a4e9f45a92 Mon Sep 17 00:00:00 2001 From: Amaury Zarzelli Date: Wed, 18 Dec 2024 21:38:54 +0100 Subject: [PATCH] feat(valhalla): allow to configure exec timeout (#112) * Merge doc/translate in develop (#107) * Test commit * test commit * test commit IDE * First draft on english documentation * Drafting the english doc * second draft of doc * Adding modifications from fr develop doc * corrections de coquilles sur les liens * corrections de coquilles sur les liens * update coquilles liens * test commit * test commit IDE * First draft on english documentation * second draft of doc * Adding modifications from fr develop doc * update coquilles liens * draft: main readme in english * fix: main readme test * fix typo test * fix : finish rebase * fix typo and switch to default french * fix readme for introduction --------- Co-authored-by: JRS * feat: handle exec maxBuffer size with environment variable * feat: update changelog * Changelog.md * Bump version in package.json * feat(valhalla): allow to configure exec timeout (#111) * feat(valhalla): allow to configure exec timeout * doc: add exec_tiemout description * doc: update changelog * Bump package.json --------- Co-authored-by: lgrd Co-authored-by: JRS Co-authored-by: Matthieu Proboeuf Co-authored-by: Aurelien --- changelog.md | 4 ++++ documentation/production/readme.md | 4 ++++ package.json | 2 +- src/js/sources/valhallaSource.js | 6 ++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 1c4fac7..3977073 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.2.8 +ADDED: +- Valhalla: allow to configure a timeout on valhalla_service exec + ## 2.2.7 ADDED: - Valhalla: Provide the ability to set maxBuffer in exec command options to avoid maxBuffer lenght exceeded error (#109) diff --git a/documentation/production/readme.md b/documentation/production/readme.md index 413add4..d94c384 100644 --- a/documentation/production/readme.md +++ b/documentation/production/readme.md @@ -72,3 +72,7 @@ Road2 peut être directement interrogé en HTTPS. Pour cela, il utilise le modul Il est possible de changer la taille du buffer lors d'une source Valhalla en valorisant la variable d'environnement `EXEC_MAX_BUFFER_SIZE`. La valeur par défaut est de 1MB. + +### Gestion du timeout valhalla +Il est possible de changer la valeur du timeout d'execution du process valhalla_service en valorisant la variable d'environnement `EXEC_TIMEOUT` (nombre de millisecondes). +La valeur par défaut est `0` soit pas de timeout. diff --git a/package.json b/package.json index 6a522a5..6c5aea4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "road2", - "version": "2.2.7", + "version": "2.2.8", "description": "Calcul d'itinéraire", "author": "RDEV - IGN", "main": "src/js/road2.js", diff --git a/src/js/sources/valhallaSource.js b/src/js/sources/valhallaSource.js index eaeedbe..d3346bc 100644 --- a/src/js/sources/valhallaSource.js +++ b/src/js/sources/valhallaSource.js @@ -19,6 +19,8 @@ const log4js = require('log4js'); const LOGGER = log4js.getLogger("VALHALLASOURCE"); // Récupération de la valeur du maxBuffer en variable d'environment variable ou valorisation par défaut (1MB) const maxBuffer = process.env.EXEC_MAX_BUFFER_SIZE ? parseInt(process.env.EXEC_MAX_BUFFER_SIZE, 10) : 1024 * 1024; +// Récupération de la valeur du timeout pour l'execution du valhalla_service en variable d'environnement ou valorisation par défaut (0) +const execTimeout = process.env.EXEC_TIMEOUT ? parseInt(process.env.EXEC_TIMEOUT, 10) : 0; /** * @@ -188,7 +190,7 @@ module.exports = class valhallaSource extends Source { // Permet de grandement se simplifier le parsing !! const optionsString = `"directions_options":{"format":"osrm"}`; const commandString = `valhalla_service ${this._configuration.storage.config} route '{${locationsString},${costingString},${optionsString}}' `; - const options = { maxBuffer: maxBuffer }; + const options = { maxBuffer: maxBuffer, timeout: execTimeout }; LOGGER.info(commandString); return new Promise( (resolve, reject) => { @@ -290,7 +292,7 @@ module.exports = class valhallaSource extends Source { const reverseString = `"reverse":${reverse}`; const polygonsString = `"polygons":true`; const commandString = `valhalla_service ${this._configuration.storage.config} isochrone '{${locationsString},${costingString},${costingOptionsString},${contoursString},${reverseString},${polygonsString}}' `; - const options = { maxBuffer: maxBuffer }; + const options = { maxBuffer: maxBuffer, timeout: execTimeout }; LOGGER.info(commandString); return new Promise( (resolve, reject) => {