mcc*_*002 3 linux .net-core azure-service-fabric
我有一个用.Net Core编写的Service Fabric应用程序。它可以在本地Windows SF群集上正常运行。它由没有Web组件的单个无状态服务组成。
我现在正尝试将其部署到Linux SF群集。我可以使用service-fabric-onebox实例在Docker中运行SF。
我使用了从azuresfcsharp也门模板中获得的entryPoint.sh文件,并更改了ServiceManifest.xml文件中的EntryPoint Program节点。我还使用dotnet cli和-r ubuntu.16.04-x64开关来编译我的项目。
现在,当我尝试部署到SF群集时,我得到
Error event: SourceId='System.Hosting', Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.The service host terminated with exit code:32512
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我终于弄明白了。我将在此处发布答案,但我还将继续执行所有步骤,以使在Windows中开发的Service Fabric项目在Linux上运行。
在SF项目的ServiceManifest.xml中,有一个EntryPoint / ExeHost / Program节点。在Windows中,这指向由msbuild生成的exe。在Linux中没有那么多。
npm i -g yonpm i -g generator-azuresfcsharpyo azuresfcsharp生成器运行时,它将为您提供SF项目文件夹和ac#项目文件夹。转到SF项目/服务名称文件夹/代码。在该文件夹中将存在两个名为entryPoint.sh和dotnet-include.sh的文件。
您需要将它们添加到项目中,并将它们设置为“内容并始终复制”。
最后,在ServiceManifest.xml中,将EntryPoint / ExeHost / Program节点更改为 entryPoint.sh
使用Visual Studio编译将无法进行,因为您需要定位linux运行时。
旁注-编译之前,您需要了解Service Fabric软件包的布局方式。右键单击Visual Studio中的SF项目,单击包,转到资源管理器中的SF项目文件夹,转到pkg并查看的最佳方法。
在控制台窗口中,cd到包含您要构建的服务的csproj文件的文件夹。假设您将部署程序包构建在pkg解决方案根目录下的文件夹中。因此运行:
dotnet publish -o ..\pkg\YourServicePkg\Code -r ubuntu.16.04-x64
Run Code Online (Sandbox Code Playgroud)
注意-pkg中的文件夹必须以Pkg结尾。
其他说明-在此处查找您可以定位的运行时列表。我刚好在使用unbuntu。运行时标识符
最后,要完善您的部署软件包,您将需要package文件夹根目录中的ApplicationManifest.xml文件,服务项目中的ServiceManifest.xml文件以及服务项目中的Config文件夹。可以在PackageRoot中找到服务项目文件
因此,您将拥有:
pkg
|
-> ApplicationManifest.xml
-> YourServicePkg
|
-> ServiceManifest.xml
-> Code (This is where you targeted dotnet publish)
-> Config
Run Code Online (Sandbox Code Playgroud)
现在您需要在本地运行它的地方。我使用了docker。这是完整设置说明的链接,但在这里我将介绍基础知识。
首先,您需要使用以下设置更新docker deamon配置:
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
Run Code Online (Sandbox Code Playgroud)
然后,拉出图像。
docker pull servicefabricoss/service-fabric-onebox
Run Code Online (Sandbox Code Playgroud)
您需要使用以下命令打开端口19080和19000
-p 19080:19080 -p 19000:19000
Run Code Online (Sandbox Code Playgroud)
如果您一直在Windows中使用Service Fabric本地群集管理器,则需要右键单击系统任务栏中的图标,然后单击“删除群集”。然后,当完成时,您需要退出。您必须删除群集,否则会发生奇怪的事情。
docker镜像启动后,打开它的bash并运行./setup.sh,然后是./run.sh
一旦SF在docker上运行并且您可以转到localhost:19080,就该使用powershell进行部署了。
首先,让我们测试我们的软件包是否有效。
Test-ServiceFabricApplicationPackage .\pkg\
Run Code Online (Sandbox Code Playgroud)
如果可行,我们进行部署
Connect-ServiceFabricCluster localhost:19000
Register-ServiceFabricApplicationType -ApplicationPathInImageStore YourService
Remove-ServiceFabricApplicationPackage -ImageStoreConnectionString fabric:ImageStore -ApplicationPackagePathInImageStore YourService
New-ServiceFabricApplication -ApplicationName fabric:/YourService -ApplicationTypeVersion 1.0.0 -ApplicationTypeName YourServiceType
Run Code Online (Sandbox Code Playgroud)
您的应用程序应在Linux中启动。
所以这就是我的意思,并导致退出代码:32512错误。
我正在使用github,显然行尾样式设置为Windows。因此,当我将其拉到另一台计算机上时,行尾从LF更改为CR LF。
要解决此问题,我必须在Notepad ++中打开受影响的文件,然后单击“编辑”->“ EOL转换”->“ Unix(LF)”。
我必须在ApplicationManifest.xml,所有ServiceManifest.xml文件以及所有entryPoint.sh和dotnet-include.sh文件上执行此操作。
| 归档时间: |
|
| 查看次数: |
875 次 |
| 最近记录: |