简体   繁体   English

分别运行 Lagom Service Locator / Kafka / Cassandra

[英]Running Lagom Service Locator / Kafka / Cassandra separately

In order to have a complete control on the components of my architecture, I'd like to deploy all the infrastructure components (Service Locator, Cassandra, Kafka) and services individually.为了完全控制我的架构组件,我想单独部署所有基础设施组件(服务定位器、Cassandra、Kafka)和服务。

I'm able to run a service with a command as follows: mvn lagom:startServiceLocator lagom:startCassandra -pl hello-impl lagom:run我可以使用如下命令运行服务: mvn lagom:startServiceLocator lagom:startCassandra -pl hello-impl lagom:run

However, when I start these components individually (ie by mvn lagom:startServiceLocator ), the started component terminates automatically.但是,当我单独启动这些组件时(即通过mvn lagom:startServiceLocator ),启动的组件会自动终止。 In this case, I see the following logs but the locator is not available at http://localhost:9008 .在这种情况下,我看到以下日志,但定位器在http://localhost:9008不可用。

I'm on a local development environment with no proxy and using the default configurations.我在没有代理并使用默认配置的本地开发环境中。

How can I run those individually?我怎样才能单独运行这些?

Java/Maven : If you want to run several Lagom microservices, you just need to do what you was doing: Java/Maven :如果你想运行几个 Lagom 微服务,你只需要做你正在做的事情:

mvn lagom:startServiceLocator lagom:startCassandra -pl hello-impl lagom:run

It will start locator, cassandra, if you need you can add kafka, after that, you just run in new cmd following command:它将启动定位器,cassandra,如果需要,您可以添加 kafka,之后,您只需在新的 cmd 中运行以下命令:

mvn -pl second-lagom-microservice-impl lagom:run

Now it will connect to running in first command cassandra and locator.现在它将连接到运行第一个命令 cassandra 和定位器。

Lagom does not allow you to run cassandra or locator without running service. Lagom 不允许您在不运行服务的情况下运行 cassandra 或定位器。

Scala/Sbt :斯卡拉/Sbt

For sbt the same approach, we need to run first microservice with all needed services:对于 sbt 采用相同的方法,我们需要运行第一个具有所有所需服务的微服务:

sbt lagomServiceLocatorStart lagomCassandraStart lagomKafkaStart microservice-impl/run

Then just run another like: **sbt another-microservice-impl/run**然后运行另一个类似: **sbt another-microservice-impl/run**

Also, you can add an alias in build.sbt for your microservice to run it individually:此外,您可以在build.sbt中添加一个别名,以便您的微服务单独运行它:

addCommandAlias(s"runMicrocervice1", ";lagomServiceLocatorStart;lagomCassandraStart;lagomKafkaStart;microservice1-impl/run")

And just run it as:并将其运行为:

sbt runMicrocervice1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM