问题
Is it possible to implement node js app as a spring eureka client? I use eureka-js-client to register spring eureka server, it always response 404 error.
回答1:
Check out the README of eureka-js-client for some helpful tips on this error.
If you are using Spring Cloud you'll likely want to set servicePath under the eureka section of your client configuration to /eureka/apps/.
回答2:
Yes It is possible, Check these three files in repo.
eureka: {
host: 'localhost',
port: 8761,
servicePath: '/eureka/apps/'
}
To this part in server.js you have to a add your own details (port and host details, If you have hosted in seperate machine you should add that machine's IP address as host)
回答3:
Eureka server can be configured for non-jvm applications such as the nodeJS using the sidecar concept. Essentially, this concept differs from the previous answer in it requires a small spring application (the sidecar) to directly discover Eureka server, handle registration and health checks. Additionally, the nodeJS application must have a designated endpoint known to the sidecar application for periodic health check status updates. A possible message provided from this health check uri could be:
{
"status":"UP"
}
You can take a look at this git repo for a sample implementation. For detail description of the sidecar concept, take a look at this documentation. The diagram below (taken from this GitHub repo above) provides a graphical explanation.
来源:https://stackoverflow.com/questions/37188035/how-node-js-app-register-to-spring-eureka