Getting the following error
Error event: SourceId='System.Hosting',
Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.Service host failed to activate. Error:0x800700c1`
If I attempt it on a linux service fabric cluster, the error changes some. So thinking the windows cluster is failing on the entyPoint.sh script as windows doesn't have bash. Linux cluster apparent getting past that and failing somewhere inside of the initialization code, but still can't find where. I added the
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
And downloaded all of the logs from the linux box, but not seeing anything from the console in there.
Error event: SourceId='System.Hosting',
Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.The service host terminated with exit code:134
Startup class looks like
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();
}
}
}
}
I haven't been able to find specifics on the error, and can't debug anything in a service fabric environment because they won't run. Any help appreciated!
I have run PerfView and found the events related to package activation, but no hints in there to what the actual issue is. Even if nobody knows what the issue is, just some help with techniques to get more information would be great!
Another thing that seems strange is that even if I comment out all of the code in the Main() method, I still get the exact same error. Almost like it is failing before it even gets there on framework dlls or something of the sort, but everything is .netcore2 and I have the runtime installed on the machine with service fabric
Apparently this happens because of different line endings in Linux and Windows. Windows systems use CR+LF while Unix and Unix-like systems use LF.
To solve your issue, perform
sed -i -e 's/\r$//' entrypoint.sh
You might need to do this if any other .sh
files where sed -i -e 's/\r$//' *.sh
helps.
Then go ahead with Service Fabric Cluster stuff!
People also play with unix2dos
and dos2unix
kind of things over such issues for which ample alternatives are listed here.
User contributions licensed under CC BY-SA 3.0