generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
27 lines (22 loc) · 963 Bytes
/
server.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
/* eslint-disable import/first,import/order */
/*
* Do appinsights first as it does some magic instrumentation work, i.e. it affects other 'require's
* In particular, applicationinsights automatically collects bunyan logs
*/
import 'applicationinsights'
import { initialiseAppInsights, buildAppInsightsClient } from './server/utils/azureAppInsights'
initialiseAppInsights()
buildAppInsightsClient()
import { setImmediate, setInterval } from 'timers'
import config from './server/config'
import { app } from './server/index'
import analyticsPrecacheTables from './server/routes/analyticsPrecacheTables'
import logger from './logger'
app.listen(app.get('port'), () => {
logger.info(`Server listening on port ${app.get('port')}`)
if (config.featureFlags.precacheTables) {
// warm up analytics table cache asynchronously now and once every hour
setImmediate(analyticsPrecacheTables)
setInterval(analyticsPrecacheTables, 60 * 60 * 1000)
}
})