diff --git a/.aws/deploy/backend-task-definition.prod.json b/.aws/deploy/backend-task-definition.prod.json index 475663f24..4de452228 100644 --- a/.aws/deploy/backend-task-definition.prod.json +++ b/.aws/deploy/backend-task-definition.prod.json @@ -103,7 +103,6 @@ "valueFrom": "PROD_INCOMING_QUEUE_URL" }, { "name": "JWT_SECRET", "valueFrom": "PROD_JWT_SECRET" }, - { "name": "KEYCDN_API_KEY", "valueFrom": "PROD_KEYCDN_API_KEY" }, { "name": "MAX_NUM_OTP_ATTEMPTS", "valueFrom": "PROD_MAX_NUM_OTP_ATTEMPTS" @@ -133,11 +132,6 @@ "name": "REDIRECT_URI", "valueFrom": "PROD_REDIRECT_URI" }, - { - "name": "REDIRECTION_REPO_GITHUB_TOKEN", - "valueFrom": "PROD_REDIRECTION_REPO_GITHUB_TOKEN" - }, - { "name": "REDIS_HOST", "valueFrom": "PROD_REDIS_HOST" }, { "name": "SESSION_SECRET", "valueFrom": "PROD_SESSION_SECRET" diff --git a/.aws/deploy/backend-task-definition.staging.json b/.aws/deploy/backend-task-definition.staging.json index 5c55e8f4d..2dcaa69a4 100644 --- a/.aws/deploy/backend-task-definition.staging.json +++ b/.aws/deploy/backend-task-definition.staging.json @@ -112,7 +112,6 @@ "valueFrom": "STAGING_INCOMING_QUEUE_URL" }, { "name": "JWT_SECRET", "valueFrom": "STAGING_JWT_SECRET" }, - { "name": "KEYCDN_API_KEY", "valueFrom": "STAGING_KEYCDN_API_KEY" }, { "name": "MAX_NUM_OTP_ATTEMPTS", "valueFrom": "STAGING_MAX_NUM_OTP_ATTEMPTS" @@ -142,11 +141,6 @@ "name": "REDIRECT_URI", "valueFrom": "STAGING_REDIRECT_URI" }, - { - "name": "REDIRECTION_REPO_GITHUB_TOKEN", - "valueFrom": "STAGING_REDIRECTION_REPO_GITHUB_TOKEN" - }, - { "name": "REDIS_HOST", "valueFrom": "STAGING_REDIS_HOST" }, { "name": "SESSION_SECRET", "valueFrom": "STAGING_SESSION_SECRET" diff --git a/src/config/config.ts b/src/config/config.ts index 87438fb99..ee6ace999 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -199,7 +199,7 @@ const config = convict({ redisHostname: { doc: "Redis host name for bullmq", env: "REDIS_HOST", - format: "required-string", + format: String, default: "isomerpages", }, }, @@ -258,7 +258,7 @@ const config = convict({ doc: "Github access to read opengovsg/isomer-redirection", env: "REDIRECTION_REPO_GITHUB_TOKEN", sensitive: true, - format: "required-string", + format: String, default: "", }, }, @@ -491,7 +491,7 @@ const config = convict({ apiKey: { doc: "KeyCDN API key", env: "KEYCDN_API_KEY", - format: "required-string", + format: String, default: "", }, }, diff --git a/src/monitoring/MonitoringService.ts b/src/monitoring/MonitoringService.ts index 3a411a9f2..8aa84fada 100644 --- a/src/monitoring/MonitoringService.ts +++ b/src/monitoring/MonitoringService.ts @@ -42,7 +42,13 @@ export default class MonitoringService { }, }) - private readonly worker: Worker + private readonly worker: Worker< + { + name: string + }, + string, + string + > private readonly monitoringWorker: MonitoringServiceInterface["monitoringWorker"] @@ -96,9 +102,15 @@ export default class MonitoringService { } ) + this.worker.on("error", (error: Error) => { + logger.error({ + message: "Monitoring service has errored", + error, + }) + }) this.worker.on("failed", (job: Job | undefined, error: Error) => { logger.error({ - message: "Monitoring service has failed", + message: "Monitoring service has errored", error, meta: { ...job?.data, diff --git a/src/monitoring/MonitoringWorker.ts b/src/monitoring/MonitoringWorker.ts index 6e092829f..9d2b28668 100644 --- a/src/monitoring/MonitoringWorker.ts +++ b/src/monitoring/MonitoringWorker.ts @@ -9,10 +9,12 @@ import parentLogger from "@logger/logger" import config from "@root/config/config" import MonitoringError from "@root/errors/MonitoringError" -import { gb } from "@root/middleware/featureFlag" import LaunchesService from "@root/services/identity/LaunchesService" import { dnsMonitor } from "@root/utils/dns-utils" -import { getMonitoringConfig } from "@root/utils/growthbook-utils" +import { + getMonitoringConfig, + getNewGrowthbookInstance, +} from "@root/utils/growthbook-utils" import promisifyPapaParse from "@root/utils/papa-parse" const IsomerHostedDomainType = { @@ -177,6 +179,10 @@ export default class MonitoringWorker { } driver() { + const gb = getNewGrowthbookInstance({ + clientKey: config.get("growthbook.clientKey"), + subscribeToChanges: true, + }) const monitoringConfig = getMonitoringConfig(gb) if (!monitoringConfig.isEnabled) { this.monitoringWorkerLogger.info("Monitoring Service disabled") diff --git a/src/utils/dns-utils.ts b/src/utils/dns-utils.ts index ebc90974c..941899286 100644 --- a/src/utils/dns-utils.ts +++ b/src/utils/dns-utils.ts @@ -2,6 +2,7 @@ import dns from "node:dns/promises" import { err, errAsync, ok, okAsync, Result, ResultAsync } from "neverthrow" +import config from "@root/config/config" import { BUILT_WITH_ISOMER_LOGO, DNS_CNAME_SUFFIXES, @@ -11,9 +12,11 @@ import { } from "@root/constants" import MonitoringError from "@root/errors/MonitoringError" import logger from "@root/logger/logger" -import { gb } from "@root/middleware/featureFlag" -import { getMonitoringConfig } from "./growthbook-utils" +import { + getMonitoringConfig, + getNewGrowthbookInstance, +} from "./growthbook-utils" export function checkCname(domain: string) { return ResultAsync.fromPromise(dns.resolveCname(domain), () => { @@ -28,11 +31,6 @@ export function checkCname(domain: string) { return okAsync(null) } - //! todo: remove, this is some colima weird logic - if (cname.length === 1 && cname[0] === domain) { - return okAsync(null) - } - return okAsync(cname[0]) }) .orElse(() => okAsync(null)) @@ -305,7 +303,10 @@ export function dnsMonitor(domain: string): ResultAsync { `${domainCheckerRes}\nThe site is still being hosted with Isomer logo, and is likely still viewable by MOP` ) } - + const gb = getNewGrowthbookInstance({ + clientKey: config.get("growthbook.clientKey"), + subscribeToChanges: true, + }) const monitoringConfig = getMonitoringConfig(gb) const isWeirdDomain = monitoringConfig.whitelistedRepos.includes( diff --git a/support/index.ts b/support/index.ts index 6568d5fa7..393bd9ccc 100644 --- a/support/index.ts +++ b/support/index.ts @@ -24,9 +24,6 @@ infraService.pollMessages() export const monitoringWorker = new MonitoringWorker({ launchesService, }) -// dnsMonitor("isomer.gov.sg").mapErr(console.log).map(console.log) -// todo: remove after testing -monitoringWorker.driver() export const monitoringService = new MonitoringService({ monitoringWorker,