forked from tsnolan23/tailor-react-spa
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
47 lines (40 loc) · 1.1 KB
/
index.js
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
47
const { initTracer, PrometheusMetricsFactory, ProbabilisticSampler } = require('jaeger-client')
const promClient = require('prom-client')
const { createLogger } = require('bunyan')
const consul = require('consul')
const { createServer } = require('http')
const { serviceName, port, tracingAddress, consulAddress } = require('./environment.js')
const microservices = require('./microservices.js')
const { requestHandler } = microservices(
consul({
host: consulAddress,
promisify: true
}),
initTracer(
{
serviceName,
reporter: {
agentHost: tracingAddress
}
},
{
host: tracingAddress,
sampler: new ProbabilisticSampler(1),
metrics: new PrometheusMetricsFactory(promClient, serviceName),
logger: createLogger({
name: serviceName
})
})
)
createServer((request, response) => {
if (request.url === '/favicon.ico') {
response.writeHead(200, { 'Content-Type': 'image/x-icon' })
response.end('')
return
} else if (request.url !== '/') {
return;
}
request.headers['x-request-uri'] = request.url
request.url = '/index'
requestHandler(request, response)
}).listen(port)