阅读背景:

如何使用Spring Cloud和Netflix的Eureka注册节点应用程序

来源:互联网 

I am trying hard to register my node app, with Netflix's Eureka , and after googling a lot, I am still looking for a solution . The max I can figure out is we have Prana but I got an issue which is still in the issue list of Prana (I guess it means my REST Template is not able to discover this app).

我正在努力注册我的节点应用程序,使用Netflix的Eureka,在谷歌搜索后,我仍在寻找解决方案。我能想到的最大值是我们有Prana,但我遇到的问题仍然在Prana的问题列表中(我猜这意味着我的REST模板无法发现这个应用程序)。

Sidecar , is another suggested solution , for which I am not getting any response . Apart from these two I have found a node module Eureka-Node-client , but none of them serve my purpose .

Sidecar,是另一个建议的解决方案,我没有得到任何回应。除了这两个,我找到了一个节点模块Eureka-Node-client,但它们都没有达到我的目的。

3 个解决方案

#1


9  

You can create a Sidecar application like you would create any spring-boot app:

您可以像创建任何spring-boot应用程序一样创建Sidecar应用程序:

@EnableSidecar
@SpringBootApplication
public class SideCarApplication {

    public static void main(final String[] args) {
        SpringApplication.run(SideCarApplication.class, args);
    }

}

The important thing is that you have to configure it to correctly register your actual service. Your application.yml should look like this:

重要的是你必须配置它才能正确注册你的实际服务。您的application.yml应如下所示:

server:
  port: 9999 -- the port your spring-boot sidecar is running
spring:
  application:
    name: nodeapplication -- the name will be your id in eureka

sidecar:
  port: 8000 -- the node applications port
  health-uri: https://localhost:8000/health.json -- the exposed health eindpoint of your node application

It is important to note that the healthpoint should return UP so your services status will be correct in eureka. The returned json for a healthy service :

重要的是要注意健康点应该返回UP,以便您的服务状态在尤里卡是正确的。返回的json用于健康服务:

{
  "status":"UP"
}

If you are having trouble setting up a spring-boot app, use https://start.spring.io/ to configure a project. Sadly there isn't a sidecar option to tick, but you will get the idea. You can do the same from STS (Spring Tool Suite).

如果您在设置spring-boot应用程序时遇到问题,请使用https://start.spring.io/配置项目。可悲的是,没有一个边车选项可以打勾,但你会得到这个想法。您可以从STS(Spring Tool Suite)执行相同的操作。

The maven dependency for Sidecar (with spring-cloud as a parent):

Sidecar的maven依赖(以spring-cloud为父):

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>

#2


0  

Checkout eureka-js-client which can be directly used in the node application to register with eureka.

Checkout eureka-js-client,可以直接在节点应用程序中使用,以便向eureka注册。

#3


-1  

I used the npm generator-express-sidecar to generate a gradlew sidecar project with all the out-of-box configurations Please refer to the reference link shared below https://www.npmjs.com/package/generator-express-sidecar

我使用npm generator-express-sidecar来生成一个带有所有开箱即用配置的gradlew sidecar项目请参考以下共享的参考链接https://www.npmjs.com/package/generator-express-sidecar


分享到: