Skip to content

Commit 273e3fe

Browse files
committed
ensure account service started before starting datalake
Signed-off-by: Alexander Onnikov <[email protected]>
1 parent 59440ba commit 273e3fe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

services/datalake/pod-datalake/src/server.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515

1616
import { Analytics } from '@hcengineering/analytics'
17+
import { getClient } from '@hcengineering/account-client'
1718
import { MeasureContext, Tx, metricsAggregate } from '@hcengineering/core'
1819
import { PlatformQueue, QueueTopic, getCPUInfo, getMemoryInfo } from '@hcengineering/server-core'
1920
import { decodeToken, TokenError } from '@hcengineering/server-token'
@@ -115,6 +116,8 @@ export async function createServer (
115116
queue: PlatformQueue,
116117
config: Config
117118
): Promise<{ app: Express, close: () => void }> {
119+
await ensureAccountReady(ctx, config)
120+
118121
const buckets: Array<{ location: Location, bucket: S3Bucket }> = []
119122
for (const bucket of config.Buckets) {
120123
const location = bucket.location as Location
@@ -348,3 +351,13 @@ export function listen (e: Express, port: number, host?: string): Server {
348351

349352
return server
350353
}
354+
355+
async function ensureAccountReady (ctx: MeasureContext, config: Config): Promise<void> {
356+
const client = getClient(config.AccountsUrl)
357+
try {
358+
await client.getRegionInfo()
359+
} catch (err: any) {
360+
ctx.error('Accounts service not ready', { err })
361+
throw new Error('Accounts service not ready')
362+
}
363+
}

0 commit comments

Comments
 (0)