简体   繁体   English

在生产中运行Lagom

[英]Running Lagom in Production

I am working on setting up a Lagom application in production. 我正在建立生产中的Lagom应用程序。 I have tried contacting Lightbend for ConductR license but haven't heard back in ages. 我曾尝试与Lightbend联系以获取ConductR许可证,但很久以前没有收到任何回音。 So, now I am looking for an alternative approach. 因此,现在我正在寻找一种替代方法。 I have multiple questions. 我有多个问题。

Since the scale of the application is pretty small right now, I think using a static service locator works for me right now (open to other alternatives). 由于应用程序的规模目前很小,我认为使用静态服务定位器现在对我有效(向其他替代方案开放)。 Also, I am using MySQL as my event store instead of the default configuration of Cassandra (Reasons not relevant to this thread). 另外,我将MySQL用作事件存储,而不是Cassandra的默认配置(与该线程无关的原因)。

To suppress Cassandra and Lagom's Service Locator, I have added the following lines to my build.sbt: 为了禁止Cassandra和Lagom的服务定位器,我在build.sbt中添加了以下几行:

lagomCassandraEnabled in ThisBuild := false

I have also added the following piece to my application.conf with service1-impl module. 我还使用service1-impl模块将以下内容添加到了application.conf中。

lagom.services {
    service1 = "http://0.0.0.0:8080"
}

For the dev environment, I have been able to successfully run my application using sbt runAll in a tmux session. 对于开发环境,我已经能够在tmux会话中使用sbt runAll成功运行我的应用程序。 With this configuration, there is no service locator running on the default 8000 port but I can individually hit service1 on 8080 port. 使用此配置,在默认的8000端口上没有运行服务定位器,但是我可以在8080端口上单独访问service1。 (Not sure if this is the expected behaviour. Comments?) (不确定这是否是预期的行为。注释?)

I ran sbt dist to create a zip file and then unzipped it and ran the executable in there. 我运行sbt dist创建一个zip文件,然后解压缩并在其中运行可执行文件。 Interestingly, the zip was created within the service1-impl folder. 有趣的是,该zip文件是在service1-impl文件夹中创建的。 So, if I have multiple modules (services?), will sbt dist create individual zip files for each of the service? 因此,如果我有多个模块(服务?),sbt dist会为每个服务创建单独的zip文件吗?

When I run the executable created via sbt dist , it tries to connect to Cassandra and also launches a service locator and ignores the static service locator configuration that I added. 当我运行通过sbt dist创建的可执行文件时,它会尝试连接到Cassandra,并启动服务定位器,并忽略我添加的静态服务定位器配置。 Basically, looks like it ignores the lines I added to build.sbt. 基本上,它似乎忽略了我添加到build.sbt的行。 Anyone who can explain this? 谁能解释这个?

Lastly, if I were to have 2 services, service1 and service2, and 2 nodes in the cluster with node 1 running service1 and node 2 running both the services, how would my static service locator look like in the application.conf and since each of the service would have its own application.conf, would I have to copy the same configuration wrt static service locator in all the application.confs? 最后,如果我要在集群中有2个服务,即service1和service2,以及2个节点,其中节点1运行service1,节点2运行这两个服务,那么我的静态服务定位符在application.conf中看起来如何,并且由于每个该服务将具有自己的application.conf,我是否必须在所有application.confs中复制相同的配置以及静态服务定位符?

Would it be something like this? 会是这样吗?

lagom.services {
    service1 = "http://0.0.0.0:8080"
    service1 = "http://1.2.3.4:8080"
    service2 = "http://1.2.3.4:8081"
}

Since each specific actor would be spawned on one of the nodes, how would it work with this service locator configuration? 由于每个特定角色都将在一个节点上生成,因此它将如何与该服务定位器配置一起工作?

Also, I don't want to run this in a tmux session in production. 另外,我不想在生产中的tmux会话中运行它。 What would be the best way to finally run this code in production? 在生产中最终运行此代码的最佳方法是什么?

You can get started with ConductR in dev mode immediately, for free, without contacting sales. 您可以立即免费在开发人员模式下开始使用ConductR,而无需联系销售人员。 Instructions are at: https://www.lightbend.com/product/conductr/developer You do need to register (read: provide a valid email) and accept TnC to access that page. 有关说明,请访问: https : //www.lightbend.com/product/conductr/developer。您确实需要注册(阅读:提供有效的电子邮件)并接受TnC访问该页面。 The sandbox is free to use for dev mode today so you can see if ConductR is right for you quickly and easily. 今天,沙盒可免费用于开发人员模式,因此您可以快速轻松地查看ConductR是否适合您。

For production, I'm thrilled to say that soon you'll be able to deploy up to 3 nodes in production if you register w/Lightbend.com (same as above) and generate a 'free tier' license key. 对于生产而言,我很高兴地说,如果您注册w / Lightbend.com(同上)并生成“免费层”许可证密钥,那么很快您将能够在生产中部署多达3个节点。

Lagom is opinionated about microservices. Lagom对微服务持坚定态度。 There's always Akka and Play if those opinions aren't shared by a project. 如果项目未共享这些意见,则总会有Akka和Play。 Part of that opinion is that deployment should be easy. 这种观点的部分原因是部署应该很容易。 Good tools feel 'right' in the hand. 好的工具会让人感觉“正确”。 You are of course free to deploy the app as you like, but be prepared to produce more polyfill the further from the marked trails you go. 当然,您可以随意部署应用程序,但要准备好在标记的路径越远的地方产生更多的polyfill。

Regarding service lookup, ConductR provides redirection for HTTP service lookups for use with 'withFollowRedirects' on Play WS [1] Regarding sbt dist , each sub-project service will be a package. 关于服务查找,ConductR提供了HTTP服务查找的重定向,以与Play WS上的“ withFollowRedirects”一起使用[1]关于sbt dist ,每个子项目服务都将是一个程序包。 You can see this in the Chirper example [2] on which sbt dist generates chirp-impl.zip, friend-impl.zip, activity-stream-impl, etc as seen in the Chirper top level build.sbt file. 您可以在Chirper示例[2]中看到这一点,在该示例中sbt dist生成chirp-impl.zip,friend-impl.zip,activity-stream-impl等,如Chirper顶级build.sbt文件中所示。 As that ConductR is the clean and lighted path, you can reference how it does things in order to better understand how to replace Lagom's deployment poly w/ your own. 由于ConductR是干净利落的路径,因此您可以参考它的工作方式,以便更好地了解如何用您自己的方式替换Lagom的部署方式。 That's the interface Lagom knows best. 那是Lagom最了解的界面。 Much of ConductR except the core is already OSS so can try github if the docs don't cover something. 除了核心已经是OSS以外,ConductR的大部分内容都是OSS,因此,如果文档没有涵盖某些内容,可以尝试github。

Disclosure: I am a ConductR-ing Lightbender. 披露:我是一个ConductRing光弯机。

  1. http://conductr.lightbend.com/docs/1.1.x/ResolvingServices http://conductr.lightbend.com/docs/1.1.x/ResolvingServices

  2. git@github.com:lagom/activator-lagom-java-chirper.git git@github.com:lagom /活化剂lagom-java的chirper.git

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

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