-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathmain.ts
46 lines (36 loc) · 1.3 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { OpenSearchService, InitService } from '@crowd/opensearch'
import { getDbConnection } from '@crowd/data-access-layer/src/database'
import { getServiceTracer } from '@crowd/tracing'
import { getServiceLogger } from '@crowd/logging'
import { getRedisClient } from '@crowd/redis'
import { getSqsClient } from '@crowd/sqs'
import { DB_CONFIG, OPENSEARCH_CONFIG, REDIS_CONFIG, SERVICE_CONFIG, SQS_CONFIG } from './conf'
import { WorkerQueueReceiver } from './queue'
const tracer = getServiceTracer()
const log = getServiceLogger()
const MAX_CONCURRENT_PROCESSING = 5
setImmediate(async () => {
log.info('Starting search sync worker...')
const openSearchService = new OpenSearchService(log, OPENSEARCH_CONFIG())
const redis = await getRedisClient(REDIS_CONFIG())
const sqsClient = getSqsClient(SQS_CONFIG())
const dbConnection = await getDbConnection(DB_CONFIG(), MAX_CONCURRENT_PROCESSING)
const worker = new WorkerQueueReceiver(
SERVICE_CONFIG().queuePriorityLevel,
redis,
sqsClient,
dbConnection,
openSearchService,
tracer,
log,
MAX_CONCURRENT_PROCESSING,
)
const initService = new InitService(openSearchService, log)
try {
await initService.initialize()
await worker.start()
} catch (err) {
log.error(err, 'Failed to start!')
process.exit(1)
}
})