How Node js app register to Spring eureka?

前提是你 提交于 2020-08-19 03:34:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!