-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregister-app.js
43 lines (38 loc) · 1.22 KB
/
register-app.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
const Eureka = require('eureka-js-client').Eureka;
const appConfig = require('./config');
const uuid = require('uuid');
const healthEndpoint = require('http');
const healthReponse = require('./resources/health');
const uniqueId = uuid.v4() || 123;
healthEndpoint.createServer(function(req, res) {
res.setHeader('Content-Type', 'application/json');
res.write(JSON.stringify(healthReponse));
res.end();
}).listen(appConfig.loggerapp.httpPort, function() {
console.log(`server health endpoint port: ${appConfig.loggerapp.httpPort}`);
});
const EurekaClient = new Eureka({
instance: {
instanceId: uniqueId,
app: 'logger-app',
hostName: appConfig.loggerapp.hostName,
ipAddr: appConfig.loggerapp.ip,
port: {
'$': appConfig.loggerapp.port,
'@enabled': true,
},
healthCheckUrl: `http://${appConfig.loggerapp.hostName}:${appConfig.loggerapp.httpPort}`,
vipAddress: 'logger-app.com',
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
'name': 'MyOwn',
},
},
eureka: {
// eureka server host / port
host: appConfig.eureka.host,
port: appConfig.eureka.port,
servicePath: '/eureka/apps/',
},
});
module.exports = EurekaClient;