diff --git a/package.json b/package.json index c96d436b3d2..36c06fe5cd8 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lint:fix:json": "eslint --ext .json --fix .", "lint": "npm run format && npm run lint:fix", "check:merge": "npm run verify || exit 1; codecov", - "start": "cd dist;node ./src/index.js;cd ..", + "start": "cd dist;exec node ./src/index.js;cd ..", "build:start": "npm run build && npm run start", "build:ci": "tsc -p tsconfig.json", "build:swagger": "npm run build && npm run setup:swagger", diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index 98f3340cad8..4130066deb9 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -20,6 +20,8 @@ const FAAS_SCALE_TARGET = process.env.FAAS_SCALE_TARGET || '4'; const FAAS_SCALE_TARGET_PROPORTION = process.env.FAAS_SCALE_TARGET_PROPORTION || '0.70'; const FAAS_SCALE_ZERO = process.env.FAAS_SCALE_ZERO || 'false'; const FAAS_SCALE_ZERO_DURATION = process.env.FAAS_SCALE_ZERO_DURATION || '15m'; +const FAAS_GUNICORN_WORKERS = process.env.FAAS_GUNICORN_WORKERS || '1'; +const FAAS_GUNICORN_THREADS = process.env.FAAS_GUNICORN_THREADS || '1'; const FAAS_BASE_IMG = process.env.FAAS_BASE_IMG || 'rudderlabs/openfaas-flask:main'; const FAAS_MAX_PODS_IN_TEXT = process.env.FAAS_MAX_PODS_IN_TEXT || '40'; const FAAS_MIN_PODS_IN_TEXT = process.env.FAAS_MIN_PODS_IN_TEXT || '1'; @@ -49,6 +51,7 @@ const CUSTOM_NETWORK_POLICY_WORKSPACE_IDS = process.env.CUSTOM_NETWORK_POLICY_WO const customNetworkPolicyWorkspaceIds = CUSTOM_NETWORK_POLICY_WORKSPACE_IDS.split(','); const CUSTOMER_TIER = process.env.CUSTOMER_TIER || 'shared'; const FAAS_SCALE_DOWN_WINDOW = process.env.FAAS_SCALE_DOWN_WINDOW || ''; // Go time values are supported ( max 5m or 300s ) +const FAAS_DNS_RESOLVER = process.env.FAAS_DNS_RESOLVER || 'false'; // Initialise node cache const functionListCache = new NodeCache(); @@ -209,6 +212,7 @@ const updateFaasFunction = async ( await updateFunction(functionName, payload); // wait for function to be ready and then set it in cache await awaitFunctionReadiness(functionName); + // set the function in cache setFunctionInCache(functionName); } catch (error) { // 404 is statuscode returned from openfaas community edition @@ -303,7 +307,11 @@ function buildOpenfaasFn(name, code, versionId, libraryVersionIDs, testMode, trM envProcess = `${envProcess} --code "${code}" --config-backend-url ${CONFIG_BACKEND_URL} --lvids "${lvidsString}"`; } - const envVars = {}; + const envVars = { + GUNICORN_WORKER_COUNT: FAAS_GUNICORN_WORKERS, + GUNICORN_THREAD_COUNT: FAAS_GUNICORN_THREADS, + dns_resolver: FAAS_DNS_RESOLVER, + }; if (FAAS_ENABLE_WATCHDOG_ENV_VARS.trim().toLowerCase() === 'true') { envVars.max_inflight = FAAS_MAX_INFLIGHT; @@ -392,7 +400,6 @@ const executeFaasFunction = async ( if (error.statusCode === 404 && error.message.includes(`error finding function ${name}`)) { removeFunctionFromCache(name); - await setupFaasFunction(name, null, versionId, libraryVersionIDs, testMode, trMetadata); throw new RetryRequestError(`${name} not found`); }