获得以下错误
Error event: SourceId='System.Hosting',
Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.Service host failed to activate. Error:0x800700c1`
如果我在linux服务结构集群上尝试它,则错误会发生变化。所以认为windows集群在entyPoint.sh脚本上失败,因为windows没有bash。 Linux集群显然越过了那个并且在初始化代码内部失败但仍无法找到位置。我添加了
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
并从linux框中下载了所有日志,但没有从控制台中看到任何内容。
Error event: SourceId='System.Hosting',
Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.The service host terminated with exit code:134
启动类看起来像
namespace MyApp
{
using System.Collections.Generic;
using System.Fabric;
using System.IO;
using System.Net.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ServiceFabric.Services.Communication.AspNetCore;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
/// <summary>
/// The FabricRuntime creates an instance of this class for each service type instance.
/// </summary>
internal sealed class MyApp : StatelessService
{
public MyApp(StatelessServiceContext context)
: base(context)
{
}
/// <summary>
/// Optional override to create listeners (like tcp, http) for this service instance.
/// </summary>
/// <returns>The collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new ServiceInstanceListener[]
{
new ServiceInstanceListener(
serviceContext =>
new KestrelCommunicationListener(
serviceContext,
"ServiceEndpoint",
(url, listener) =>
{
ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting WebListener on {url}");
return new WebHostBuilder()
.UseKestrel()
.ConfigureServices(
services => services
.AddSingleton<ConfigSettings>(new ConfigSettings(serviceContext))
.AddSingleton<HttpClient>(new HttpClient())
.AddSingleton<FabricClient>(new FabricClient())
.AddSingleton<StatelessServiceContext>(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
.UseStartup<Startup>()
.UseUrls(url)
.Build();
}))
};
}
}
Program.cs的
namespace MyApp
{
using System;
using System.Diagnostics;
using System.Threading;
using CommandLine;
using Microsoft.AspNetCore.Hosting;
using Microsoft.ServiceFabric.Services.Runtime;
internal static class Program
{
/// <summary>
/// This is the entry point of the service host process.
/// </summary>
private static void Main(string[] args)
{
var parser = new Parser(with =>
{
with.HelpWriter = Console.Out;
});
var options = new Options();
var result = parser.ParseArguments(args, options);
if (options.Host.ToLower() == MyAppConstants.ServiceFabricHost)
{
try
{
// The ServiceManifest.XML file defines one or more service type names.
// Registering a service maps a service type name to a .NET type.
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
ServiceRuntime.RegisterServiceAsync(
"WebServiceType",
context => new MyApp(context)).GetAwaiter().GetResult();
ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(SnapNurse).Name);
// Prevents this host process from terminating so services keeps running.
Thread.Sleep(Timeout.Infinite);
}
catch (Exception e)
{
ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
throw;
}
}
else if (options.Host.ToLower() == MyAppConstants.SelfHost)
{
using (var host = WebHostBuilderHelper.GetWebHost(new WebHostBuilder(), options.Protocol, options.Port))
{
host.Run();
}
}
}
}
我无法找到有关错误的详细信息,也无法在服务结构环境中调试任何内容,因为它们无法运行。任何帮助表示赞赏!
我已经运行了PerfView并发现了与包激活相关的事件,但没有提示实际问题是什么。即使没有人知道问题是什么,只需要一些技巧来获取更多信息就会很棒!
另一件似乎很奇怪的事情是,即使我注释掉Main()方法中的所有代码,我仍然会得到完全相同的错误。几乎就像它在它甚至到达框架dll或类似的东西之前失败,但一切都是.netcore2并且我在服务器结构的机器上安装了运行时
答案 0 :(得分:1)
显然,这是因为Linux和Windows中的行结尾不同。 Windows系统使用CR + LF,而Unix和类Unix系统使用LF。
要解决您的问题,请执行
sed -i -e 's/\r$//' entrypoint.sh
如果.sh
有帮助的其他sed -i -e 's/\r$//' *.sh
个文件,您可能需要执行此操作。
然后继续使用Service Fabric Cluster!
人们还会在unix2dos
上列出dos2unix
和<agm-circle *ngFor="let data of circle"
[latitude]="data.lat"
[longitude]="data.lng"
[circleDraggable]="true"
[editable]="true"
[fillColor]="data.color"
[radius]="data.radius"
>
</agm-circle>
类似的问题,并列出了充足的替代方案{。{3}}。