Service Fabric具有配置覆盖的多个服务实例 [英] Service Fabric Multiple service instances with config override

查看:99
本文介绍了Service Fabric具有配置覆盖的多个服务实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的服务结构应用程序包括无状态服务,该服务通过OwinCommunicationListener公开HTTP终结点.

Our service fabric application includes a stateless service that exposes an HTTP endpoint through OwinCommunicationListener.

此服务的ServiceManifest.Xml指定服务端点<Endpoint Name="ServiceEndpoint" Type="Input" Protocol="http" Port="8090" />

The ServiceManifest.Xml for this service specifies the service endpoint <Endpoint Name="ServiceEndpoint" Type="Input" Protocol="http" Port="8090" />

然后可以通过 http://localhost:8090/

我们想要做的是通过ApplicationManifest在同一Service Fabric应用程序中的不同终结点上实例化此服务的多个实例.

What we are trying to do is instantiate multiple instances of this service on different endpoints in the same Service Fabric application through the ApplicationManifest.

ServiceManifestImport导入我们的服务包,并允许在应用程序级别覆盖配置.我们无法以这种方式覆盖ServiceEndpoint,仅覆盖Settings.xml中的值

The ServiceManifestImport imports our service package and allows configuration overrides at the application level. We're not able to override the ServiceEndpoint this way, only the values in Settings.xml

<ServiceManifestImport>
  <ServiceManifestRef ServiceManifestName="FooServicePkg" ServiceManifestVersion="1.0.0" >
    <ConfigOverrides Name="Config">
      <Settings>
        <SectionName Name="MySettings">
        <Parameter Name="MySetting" Value="SomeValue">
      </Settings>
    </ConfigOverrides>
</ServiceManifestImport>

我们可以通过在DefaultServices

<DefaultServices>
  <Service Name="FooInstanceA">
    <StatelessService ServiceTypeName="FooType" InstanceCount="1" />
      <SingletonPartition />
    </StatelessService>
  </Service>
  <Service Name="FooInstanceB">
    <StatelessService ServiceTypeName="FooType" InstanceCount="1" />
      <SingletonPartition />
    </StatelessService>
  </Service>
</DefaultServices>

是否可以通过配置为每个服务实例指定配置替代?

我试图通过使用服务名称来确定服务实例在特定端口上的侦听,以便FooInstanceA在端口8090上侦听,而FooInstanceB在8091上侦听.

I tried to make the service instances listen on a specific port by using their service name to work out which port so FooInstanceA listens on port 8090 and FooInstanceB listens on 8091.

很显然,Service Fabric在部署过程中表现得有些神奇,因为当FooInstanceB侦听ServiceEndpoint配置上指定的端口以外的端口时,该服务将不可访问.

Clearly Service Fabric is doing some magic during deployment because when FooInstanceB listens on a port other than the one specified on the ServiceEndpoint configuration the service is not accessible.

第一个原因是未在端点上设置DACL,这可以通过运行来解决;

The first reason is the DACL is not set on the endpoint, this is resolved by running;

netsh http add urlacl http://+:8091/ user=everyone listen=yes

这允许服务启动并在Service Fabric资源管理器中正常运行,但是当我们使用 http访问时,FooInstanceB响应时显示HTTP 503错误://localhost:8091/

This allows the services to come up and show healthy in the Service Fabric Explorer, however the FooInstanceB is responding with an HTTP 503 error when we access with http://localhost:8091/

我们如何让服务实例在不同的端口上监听?

我希望这很清楚,谢谢.

I hope that's clear, thank you.

推荐答案

要实现此目的,没有很多不错的选择.这里有一些想法:

Not a lot of great options to accomplish this. Here are some ideas:

  1. 在一个应用程序中创建多个应用程序实例,而不是多个相同类型的服务.这样一来,您就可以使用应用程序参数来配置特定服务的行为.
  2. 在您的服务类型中创建多个配置包.每个配置包都将用于其中一个服务实例.确定服务实例分配给哪个配置包需要动态,也许基于服务实例的名称?当然,这不是一个很好的选择,因为它将服务定义与将要创建的实例数量结合在一起.
  3. 自定义配置实现.也许让您的服务公开一个端点,使您可以在部署后对其进行配置.或者让该服务调用其他一些在激活时提供其配置的管理服务.

这篇关于Service Fabric具有配置覆盖的多个服务实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆