From b624a4780b36306abe6308898b3c87a58a47f58c Mon Sep 17 00:00:00 2001 From: Hasan Mammed-zadeh Date: Fri, 26 Apr 2019 15:04:26 +0200 Subject: [PATCH 1/4] #56 add posibility to set keepAliveTimeout --- notification/src/config/config.js | 4 +++- notification/src/init.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/notification/src/config/config.js b/notification/src/config/config.js index 1dca78c93..90e4211f6 100644 --- a/notification/src/config/config.js +++ b/notification/src/config/config.js @@ -6,7 +6,9 @@ let config function getEnvConfig () { return { - logLevel: process.env.LOG_LEVEL + logLevel: process.env.LOG_LEVEL, + keepAliveTimeout: !Number.isNaN(process.env.KEEP_ALIVE_TIMEOUT) ? parseFloat(process.env.KEEP_ALIVE_TIMEOUT, 10) + : undefined } } diff --git a/notification/src/init.js b/notification/src/init.js index ca225ae74..21fdde1ec 100644 --- a/notification/src/init.js +++ b/notification/src/init.js @@ -8,6 +8,8 @@ const ctpClient = ctp.get(config) const PORT = process.env.PORT || 443 +if (config.keepAliveTimeout !== undefined) + server.keepAliveTimeout = config.keepAliveTimeout server.listen(PORT, async () => { await ensureInterfaceInteractionCustomType(ctpClient) logger.info(`Server started on ${PORT} port`) From 5c9800280b118e857c94730260ab2540f2c0307c Mon Sep 17 00:00:00 2001 From: Hasan Mammed-zadeh Date: Fri, 26 Apr 2019 15:14:24 +0200 Subject: [PATCH 2/4] #56 add a new env variable to documentation --- notification/docs/DevelopmentGuide.md | 1 + notification/docs/IntegrationGuide.md | 1 + 2 files changed, 2 insertions(+) diff --git a/notification/docs/DevelopmentGuide.md b/notification/docs/DevelopmentGuide.md index 2fbd23280..8733f834a 100644 --- a/notification/docs/DevelopmentGuide.md +++ b/notification/docs/DevelopmentGuide.md @@ -25,6 +25,7 @@ CTP_CLIENT_ID | commercetools client ID with `manage_types` and `manage_payments CTP_CLIENT_SECRET | commercetools client secret (you can get in the [commercetools Merchant Center](https://mc.commercetools.com)) | **YES** | LOG_LEVEL | bunyan log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`)| NO | `info` PORT | port on which the application will run | NO | 443 +KEEP_ALIVE_TIMEOUT | milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout)) | NO | Node.js default Don't forget to provide all required environment variables After setting all variables, execute command `npm run start` to run the module. diff --git a/notification/docs/IntegrationGuide.md b/notification/docs/IntegrationGuide.md index 5ea3b2a52..28b13cf96 100644 --- a/notification/docs/IntegrationGuide.md +++ b/notification/docs/IntegrationGuide.md @@ -37,6 +37,7 @@ CTP_CLIENT_ID | commercetools client ID (you can get in the commercetools Mercha CTP_CLIENT_SECRET | commercetools client secret (you can get in the commercetools Merchant Center) | **YES** | LOG_LEVEL | bunyan log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`)| NO | `info` PORT | port on which the application will run | NO | 443 +KEEP_ALIVE_TIMEOUT | milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout)) | NO | Node.js default Check out the deployment [Best Practices documentation](../../docs/BEST_PRACTICES.md) From 1c644d89c8258594470ca5413a74f24b95bd82d9 Mon Sep 17 00:00:00 2001 From: Hasan Mammed-zadeh Date: Fri, 26 Apr 2019 15:26:39 +0200 Subject: [PATCH 3/4] #56 add KEEP_ALIVE_TIMEOUT env variable for extension module --- extension/src/config/config.js | 4 +++- extension/src/init.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extension/src/config/config.js b/extension/src/config/config.js index a85f18e87..0d4cf50f3 100644 --- a/extension/src/config/config.js +++ b/extension/src/config/config.js @@ -4,7 +4,9 @@ function getEnvConfig () { return { port: process.env.PORT, logLevel: process.env.LOG_LEVEL, - apiExtensionBaseUrl: process.env.API_EXTENSION_BASE_URL + apiExtensionBaseUrl: process.env.API_EXTENSION_BASE_URL, + keepAliveTimeout: !Number.isNaN(process.env.KEEP_ALIVE_TIMEOUT) ? parseFloat(process.env.KEEP_ALIVE_TIMEOUT, 10) + : undefined } } diff --git a/extension/src/init.js b/extension/src/init.js index 4f5956ea8..ca7cb623e 100644 --- a/extension/src/init.js +++ b/extension/src/init.js @@ -6,6 +6,8 @@ const { ensureResources } = require('./config/init/ensure-resources') const port = parseInt(process.env.EXTENSION_PORT || 8080, 10) const logger = utils.getLogger() +if (config.keepAliveTimeout !== undefined) + server.keepAliveTimeout = config.keepAliveTimeout init.listen(port, async () => { await ensureResources() logger.info(`Server running at http://127.0.0.1:${port}/`) From 108837b8892a2b53a86991da393ca7125083962f Mon Sep 17 00:00:00 2001 From: Hasan Mammed-zadeh Date: Fri, 26 Apr 2019 15:26:51 +0200 Subject: [PATCH 4/4] #56 add KEEP_ALIVE_TIMEOUT env variable to docs of extension module --- extension/docs/IntegrationGuide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/extension/docs/IntegrationGuide.md b/extension/docs/IntegrationGuide.md index 6185cc898..85d86ebfe 100644 --- a/extension/docs/IntegrationGuide.md +++ b/extension/docs/IntegrationGuide.md @@ -45,6 +45,7 @@ In order to make the extension module working, following parameters have to be p | `API_EXTENSION_BASE_URL` | URL of the Extension module. This URL will be called by CTP Extension endpoint. | | `ADYEN_API_KEY` | Go to [Account/Users](https://ca-test.adyen.com/ca/ca/config/users.shtml) - Select a user with `Web Service` User type - Generate New API Key (notice: in case you get `403 Forbidden` error from Adyen, try to regenerate the key). | | `ADYEN_MERCHANT_ACCOUNT` | Go to [Account/Merchant accounts](https://ca-test.adyen.com/ca/ca/accounts/show.shtml?accountTypeCode=MerchantAccount) and get the name in Acccount code. | | +| `KEEP_ALIVE_TIMEOUT` | milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout)) | # Checkout steps In your shop, ensure the steps below are done: