Updating how default environment variables are handled, so that the defaults are easier to access.
This commit is contained in:
parent
72875a728c
commit
77225e6eb9
|
@ -1,4 +1,6 @@
|
||||||
import { Duration } from "@budibase/backend-core"
|
import { Duration } from "@budibase/backend-core"
|
||||||
|
import env from "../environment"
|
||||||
|
|
||||||
|
const defaults = env.getDefaults()
|
||||||
export const AUTOMATION_SYNC_TIMEOUT = Duration.fromMinutes(2).toMs()
|
export const AUTOMATION_SYNC_TIMEOUT = Duration.fromMinutes(2).toMs()
|
||||||
export const AUTOMATION_ASYNC_TIMEOUT = Duration.fromSeconds(12).toMs()
|
export const AUTOMATION_ASYNC_TIMEOUT = defaults.QUERY_THREAD_TIMEOUT
|
||||||
|
|
|
@ -18,6 +18,20 @@ function parseIntSafe(number?: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULTS = {
|
||||||
|
QUERY_THREAD_TIMEOUT: 10000,
|
||||||
|
AUTOMATION_THREAD_TIMEOUT: 12000,
|
||||||
|
AUTOMATION_MAX_ITERATIONS: 200,
|
||||||
|
JS_PER_EXECUTION_TIME_LIMIT_MS: 1000,
|
||||||
|
TEMPLATE_REPOSITORY: "app",
|
||||||
|
PLUGINS_DIR: "/plugins",
|
||||||
|
FORKED_PROCESS_NAME: "main",
|
||||||
|
JS_RUNNER_MEMORY_LIMIT: 64,
|
||||||
|
}
|
||||||
|
|
||||||
|
const QUERY_THREAD_TIMEOUT =
|
||||||
|
parseIntSafe(process.env.QUERY_THREAD_TIMEOUT) ||
|
||||||
|
DEFAULTS.QUERY_THREAD_TIMEOUT
|
||||||
const environment = {
|
const environment = {
|
||||||
// features
|
// features
|
||||||
APP_FEATURES: process.env.APP_FEATURES,
|
APP_FEATURES: process.env.APP_FEATURES,
|
||||||
|
@ -42,7 +56,8 @@ const environment = {
|
||||||
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
||||||
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
|
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
|
||||||
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
||||||
TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY || "app",
|
TEMPLATE_REPOSITORY:
|
||||||
|
process.env.TEMPLATE_REPOSITORY || DEFAULTS.TEMPLATE_REPOSITORY,
|
||||||
DISABLE_AUTO_PROD_APP_SYNC: process.env.DISABLE_AUTO_PROD_APP_SYNC,
|
DISABLE_AUTO_PROD_APP_SYNC: process.env.DISABLE_AUTO_PROD_APP_SYNC,
|
||||||
SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD,
|
SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD,
|
||||||
// minor
|
// minor
|
||||||
|
@ -50,16 +65,20 @@ const environment = {
|
||||||
LOGGER: process.env.LOGGER,
|
LOGGER: process.env.LOGGER,
|
||||||
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
|
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
|
||||||
AUTOMATION_MAX_ITERATIONS:
|
AUTOMATION_MAX_ITERATIONS:
|
||||||
parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200,
|
parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) ||
|
||||||
|
DEFAULTS.AUTOMATION_MAX_ITERATIONS,
|
||||||
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
||||||
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
||||||
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT) || 10000,
|
QUERY_THREAD_TIMEOUT: QUERY_THREAD_TIMEOUT,
|
||||||
AUTOMATION_THREAD_TIMEOUT:
|
AUTOMATION_THREAD_TIMEOUT:
|
||||||
parseIntSafe(process.env.AUTOMATION_THREAD_TIMEOUT) || 12000,
|
parseIntSafe(process.env.AUTOMATION_THREAD_TIMEOUT) ||
|
||||||
|
DEFAULTS.AUTOMATION_THREAD_TIMEOUT > QUERY_THREAD_TIMEOUT
|
||||||
|
? DEFAULTS.AUTOMATION_THREAD_TIMEOUT
|
||||||
|
: QUERY_THREAD_TIMEOUT,
|
||||||
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
||||||
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
||||||
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
||||||
PLUGINS_DIR: process.env.PLUGINS_DIR || "/plugins",
|
PLUGINS_DIR: process.env.PLUGINS_DIR || DEFAULTS.PLUGINS_DIR,
|
||||||
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
|
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
|
||||||
MAX_IMPORT_SIZE_MB: process.env.MAX_IMPORT_SIZE_MB,
|
MAX_IMPORT_SIZE_MB: process.env.MAX_IMPORT_SIZE_MB,
|
||||||
SESSION_EXPIRY_SECONDS: process.env.SESSION_EXPIRY_SECONDS,
|
SESSION_EXPIRY_SECONDS: process.env.SESSION_EXPIRY_SECONDS,
|
||||||
|
@ -72,12 +91,21 @@ const environment = {
|
||||||
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
||||||
SELF_HOSTED: process.env.SELF_HOSTED,
|
SELF_HOSTED: process.env.SELF_HOSTED,
|
||||||
HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT,
|
HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT,
|
||||||
FORKED_PROCESS_NAME: process.env.FORKED_PROCESS_NAME || "main",
|
FORKED_PROCESS_NAME:
|
||||||
|
process.env.FORKED_PROCESS_NAME || DEFAULTS.FORKED_PROCESS_NAME,
|
||||||
JS_PER_INVOCATION_TIMEOUT_MS:
|
JS_PER_INVOCATION_TIMEOUT_MS:
|
||||||
parseIntSafe(process.env.JS_PER_EXECUTION_TIME_LIMIT_MS) || 1000,
|
parseIntSafe(process.env.JS_PER_EXECUTION_TIME_LIMIT_MS) ||
|
||||||
|
DEFAULTS.JS_PER_EXECUTION_TIME_LIMIT_MS,
|
||||||
JS_PER_REQUEST_TIMEOUT_MS: parseIntSafe(
|
JS_PER_REQUEST_TIMEOUT_MS: parseIntSafe(
|
||||||
process.env.JS_PER_REQUEST_TIME_LIMIT_MS
|
process.env.JS_PER_REQUEST_TIME_LIMIT_MS
|
||||||
),
|
),
|
||||||
|
TOP_LEVEL_PATH:
|
||||||
|
process.env.TOP_LEVEL_PATH || process.env.SERVER_TOP_LEVEL_PATH,
|
||||||
|
APP_MIGRATION_TIMEOUT: parseIntSafe(process.env.APP_MIGRATION_TIMEOUT),
|
||||||
|
JS_RUNNER_MEMORY_LIMIT:
|
||||||
|
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) ||
|
||||||
|
DEFAULTS.JS_RUNNER_MEMORY_LIMIT,
|
||||||
|
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
|
||||||
// old
|
// old
|
||||||
CLIENT_ID: process.env.CLIENT_ID,
|
CLIENT_ID: process.env.CLIENT_ID,
|
||||||
_set(key: string, value: any) {
|
_set(key: string, value: any) {
|
||||||
|
@ -94,12 +122,9 @@ const environment = {
|
||||||
isInThread: () => {
|
isInThread: () => {
|
||||||
return process.env.FORKED_PROCESS
|
return process.env.FORKED_PROCESS
|
||||||
},
|
},
|
||||||
TOP_LEVEL_PATH:
|
getDefaults: () => {
|
||||||
process.env.TOP_LEVEL_PATH || process.env.SERVER_TOP_LEVEL_PATH,
|
return DEFAULTS
|
||||||
APP_MIGRATION_TIMEOUT: parseIntSafe(process.env.APP_MIGRATION_TIMEOUT),
|
},
|
||||||
JS_RUNNER_MEMORY_LIMIT:
|
|
||||||
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64,
|
|
||||||
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up any environment variable edge cases
|
// clean up any environment variable edge cases
|
||||||
|
|
Loading…
Reference in New Issue