diff --git a/helm_deploy/values-prod.yaml b/helm_deploy/values-prod.yaml index 052601c..b4f617f 100644 --- a/helm_deploy/values-prod.yaml +++ b/helm_deploy/values-prod.yaml @@ -2,7 +2,7 @@ # Per environment values which override defaults in hmpps-component-dependencies/values.yaml redis: - secretName: elasticache-redis-dev + secretName: elasticache-redis apis: serviceCatalogue: diff --git a/src/run.ts b/src/run.ts index 769953a..ade5de8 100644 --- a/src/run.ts +++ b/src/run.ts @@ -1,4 +1,4 @@ -import initialiseAppInsights from './utils/appInsights' +import initialiseAppInsights, { flush } from './utils/appInsights' import applicationInfo from './utils/applicationInfo' import config, { type Environment } from './config' @@ -45,9 +45,11 @@ const run = async () => { logger.info(`Finished publishing dependency info`) await redisClient.quit() + await flush() } -run().catch(e => { +run().catch(async e => { logger.error(e) + await flush() process.exit(1) }) diff --git a/src/utils/appInsights.ts b/src/utils/appInsights.ts index a0f6b27..5847e28 100644 --- a/src/utils/appInsights.ts +++ b/src/utils/appInsights.ts @@ -13,3 +13,9 @@ export default function initialiseAppInsights({ applicationName, buildNumber }: } return null } + +export async function flush(): Promise { + if (process.env.APPINSIGHTS_INSTRUMENTATIONKEY) { + await defaultClient.flush() + } +}