在服务布料,我可以改变使用应用程序参数的ServiceManifest.xml文件中的参数? [英] In Service Fabric, can I alter the Arguments in the ServiceManifest.xml file using Application Parameters?

查看:167
本文介绍了在服务布料,我可以改变使用应用程序参数的ServiceManifest.xml文件中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ApplicationManifest.xml文件看起来像:

I have an ApplicationManifest.xml file that looks like:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric"
   ApplicationTypeName="ServiceFabricTestType" ApplicationTypeVersion="1.9">
   <Parameters>
     <Parameter Name="Prop_BehavioursPath" DefaultValue="behaviours.yml"/>
     <Parameter Name="Prop_AliasesPath" DefaultValue="aliases.yml"/>
   </Parameters>
  <ServiceManifestImport>
  <ServiceManifestRef 
    ServiceManifestName="SummaryGenerator" 
    ServiceManifestVersion="1.9.0.0" 
    />
  </ServiceManifestImport>
</ApplicationManifest>

和我想用参数来调整我的客人托管服务的说法,像这样一个ServiceManifest.xml文件中声明:

And I want to use the parameters to adjust the Argument of my guest hosted service, declared in a ServiceManifest.xml file like so:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric"
   Name="SummaryGenerator" Version="1.9.0.0">
   <ServiceTypes>
     <StatelessServiceType ServiceTypeName="SummaryGenerator" UseImplicitHost="true"/>
   </ServiceTypes>
   <CodePackage Name="code" Version="1.9.0.0">
   <EntryPoint>
     <ExeHost>
        <Program>MyProgram.exe</Program>
        <Arguments>&quot;LoadFrom=[Prop_AliasesPath]|[Prop_BehavioursPath]&quot;</Arguments>
        <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
     </ExeHost>
   </EntryPoint>
  </CodePackage>
</ServiceManifest>

这显然不作为进入参数的性能被视为逐字记录和未解决的参数值。工作

This clearly doesn't work as the properties going into the Arguments are treated as verbatim and not resolved from the parameter values.

我真正想要做的是能启动服务,并通过为Prop_BehavioursPath和Prop_Alias​​esPath不同的值。有没有更好的方式服务织物做到这一点?

What I really want to do is to be able to start a service and pass in different values for Prop_BehavioursPath and Prop_AliasesPath. Is there a better way to do this in Service Fabric?

应用程序正在运行不知道服务面料,并通过它可通过命令行参数来将配置的唯一途径。

The application being run doesn't know about Service Fabric and the only way to push configuration through to it is via the command arguments.

推荐答案

看起来不像你可以做到这一点......相反,你可以尝试,你写一个小的.NET包装,上面写着顺丰配置的解决方法和然后启动你的客人的可执行文件。你可以标准输入/输出从子进程重定向和连接它的退出事件,以及因此主要的进程终止时,子进程终止。

Doesn't look like you can do that... Instead, you could try a workaround where you write a small .NET wrapper that reads the sf configuration and then launches your guest executable. You could redirect stdin/stdout from the child process and hook into it's exited event as well so the main process terminates when the child terminates.

这篇关于在服务布料,我可以改变使用应用程序参数的ServiceManifest.xml文件中的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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