-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 861 Bytes
/
index.js
File metadata and controls
32 lines (29 loc) · 861 Bytes
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
'use strict'
require('loadenv')()
const Promise = require('bluebird')
const CriticalError = require('error-cat/errors/critical-error')
const ErrorCat = require('error-cat')
const log = require('logger').child({ module: 'main' })
const workerServer = require('worker-server')
const rabbitmq = require('rabbitmq')
const mongodbClient = require('mongo-helper').client
Promise.join(
mongodbClient.connectAsync(),
rabbitmq.publisher.connect()
)
.spread((mongoClient) => {
log.info('rabbimq publisher started')
return workerServer.start()
.then(() => {
log.info('all components started')
})
})
.catch((err) => {
log.fatal({ err: err }, 'Pheidi server failed to start')
mongodbClient.closeAsync()
ErrorCat.report(new CriticalError(
'server failed to start',
{ err: err }
))
process.exit(1)
})