8

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

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

4

3 回答 3

9

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

@EnableSidecar
@SpringBootApplication
public class SideCarApplication {

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

}

重要的是您必须对其进行配置以正确注册您的实际服务。你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: http://localhost:8000/health.json -- the exposed health eindpoint of your node application

重要的是要注意 healthpoint 应该返回UP,以便您的服务状态在 eureka 中是正确的。返回的健康服务的 json :

{
  "status":"UP"
}

如果您在设置spring-boot应用程序时遇到问题,请使用https://start.spring.io/配置项目。遗憾的是,没有边车选项可供选择,但您会明白的。您可以从STS(Spring Tool Suite)中执行相同的操作。

maven 依赖Sidecar项(以 spring-cloud 作为父级):

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>
于 2015-10-08T16:01:40.247 回答
0

出eureka-js-client,可以直接在node应用中使用,注册eureka。

于 2018-01-11T12:59:35.403 回答
-1

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

于 2017-06-20T18:47:02.930 回答