diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index ed882fe96a..138dbbd9e0 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -107,6 +107,7 @@ const environment = { ENCRYPTION_KEY: process.env.ENCRYPTION_KEY, API_ENCRYPTION_KEY: getAPIEncryptionKey(), COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005", + COUCH_DB_SQL_URL: process.env.COUCH_DB_SQL_URL || "http://localhost:4984", COUCH_DB_USERNAME: process.env.COUCH_DB_USER, COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID, diff --git a/packages/worker/src/api/controllers/system/environment.ts b/packages/worker/src/api/controllers/system/environment.ts index ade5f241e2..c619d484f7 100644 --- a/packages/worker/src/api/controllers/system/environment.ts +++ b/packages/worker/src/api/controllers/system/environment.ts @@ -1,6 +1,25 @@ import { Ctx } from "@budibase/types" import env from "../../../environment" import { env as coreEnv } from "@budibase/backend-core" +import nodeFetch from "node-fetch" + +let sqsAvailable: boolean +async function isSqsAvailable() { + if (sqsAvailable !== undefined) { + return sqsAvailable + } + + try { + await nodeFetch(coreEnv.COUCH_DB_SQL_URL, { + timeout: 1000, + }) + } catch (e) { + sqsAvailable = false + return false + } + sqsAvailable = true + return true +} export const fetch = async (ctx: Ctx) => { ctx.body = { @@ -11,5 +30,6 @@ export const fetch = async (ctx: Ctx) => { disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL, baseUrl: env.PLATFORM_URL, isDev: env.isDev() && !env.isTest(), + isSqsAvailable: await isSqsAvailable(), } }