From e39b9e284d1f0a3af8ba668db75584462c560004 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 2 Jan 2019 21:18:52 -0800 Subject: [PATCH] feat(create_index): exit with warnings if header size settings are not in effect This avoids issues with Elasticsearch 5 headers and Node.js 8.14/10.14 as described in https://github.com/pelias/schema/pull/339 --- package.json | 3 ++- scripts/create_index.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d88c7ca5..eb5c94cb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "elasticsearch": "^15.0.0", "joi": "^14.0.0", "lodash.merge": "^4.6.0", - "pelias-config": "^3.5.0" + "pelias-config": "^3.5.0", + "pelias-logger": "^1.3.0" }, "devDependencies": { "difflet": "^1.0.1", diff --git a/scripts/create_index.js b/scripts/create_index.js index 7b069abf..72ea4a49 100644 --- a/scripts/create_index.js +++ b/scripts/create_index.js @@ -2,6 +2,7 @@ const child_process = require('child_process'); const http = require('http'); const config = require('pelias-config').generate(); +const logger = require('pelias-logger').get('schema'); const es = require('elasticsearch'); const cli = require('./cli'); @@ -17,6 +18,20 @@ try { process.exit(1); } +if (http.maxHeaderSize === undefined) { + logger.warning('You are using a version of Node.js that does not support the --max-http-header-size option.' + + 'You may experience issues when using Elasticsearch 5.' + + 'See https://github.com/pelias/schema#compatibility for more details.'); +} + +if (http.maxHeaderSize < 16384) { + logger.error('Max header size is below 16384 bytes. ' + + 'Be sure to use the provided wrapper script in \'./bin\' rather than calling this script directly.' + + 'Otherwise, you may experience issues when using Elasticsearch 5.' + + 'See https://github.com/pelias/schema#compatibility for more details.'); + process.exit(1); +} + cli.header("create index"); const indexName = config.schema.indexName;