diff --git a/changelog.md b/changelog.md index fda6a48a..4d60b31d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.2.7 +ADDED: +- Valhalla: Provide the ability to set maxBuffer in exec command options to avoid maxBuffer lenght exceeded error + ## 2.2.6 FIXED: - Ignore turf errors for steps simplification in pgrSource, and add a warning to analyse which steps trigger the error diff --git a/documentation/production/readme.md b/documentation/production/readme.md index 39c85266..413add40 100644 --- a/documentation/production/readme.md +++ b/documentation/production/readme.md @@ -67,3 +67,8 @@ Par défaut, il y a des options qui sont utilisées mais elles peuvent être rem ### Gestion du HTTPS Road2 peut être directement interrogé en HTTPS. Pour cela, il utilise le module `https` de NodeJS. Il est donc possible de lui fournir les [options](https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) disponibles dans ce module. + +### Gestion du buffer + +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. diff --git a/src/js/sources/valhallaSource.js b/src/js/sources/valhallaSource.js index b15adb55..eaeedbe0 100644 --- a/src/js/sources/valhallaSource.js +++ b/src/js/sources/valhallaSource.js @@ -17,6 +17,8 @@ const { exec } = require('child_process'); // Création du LOGGER 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; /** * @@ -186,12 +188,13 @@ 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 }; LOGGER.info(commandString); return new Promise( (resolve, reject) => { try { - exec(commandString, (err, stdout, stderr) => { + exec(commandString, options, (err, stdout, stderr) => { // Du moment qu'OSRM a répondu, on considère que la source est joignable this.state = "green"; @@ -287,12 +290,13 @@ 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 }; LOGGER.info(commandString); return new Promise( (resolve, reject) => { try { - exec(commandString, (err, stdout, stderr) => { + exec(commandString, options, (err, stdout, stderr) => { // Du moment qu'OSRM a répondu, on considère que la source est joignable this.state = "green";