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: 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}/`) 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) 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`)