0

First, Docker novice. Attempting to run a .Net5 Worker Service on a mcr.microsoft.com/windows/servercore:1909 docker image with the .Net5 and 3.1 sdks installed onto the system.

The Service is being installed by a C# program (its part of a larger package) that is using a wrapper for the advapi32.dll to create and otherwise work with the Windows Services and SCM. On other computers, including the host system, the service is installed correctly and will continue running. After installation on the docker image, the service (startup as AutomaticDelayed) is created but will return "The service did not respond to the start or control request in a timely fashion" as the only error.

Both from viewing the logs and running the service manually (from powershell) on the docker container, the service will continue running until the SCM kills it from timeout. I have extended ServicesPipeTimeout registry item to 10 minutes and the SCM will still timeout the application after it fails to respond.

Any thoughts?

EDIT: Had question about using .UseWindowsService() but we were already using that. This is the program main that all our services are using.

public class Program
{
    public static void Main(string[] args)
    {
        if (!IsDebug())
            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureServices((hostContext, services) =>
            {
                services.AddSingleton<SingletonHandler>();
                services.AddHostedService<Worker>();
                services.AddHostedService<Listener>();
            })
         .ConfigureLogging((hostingContext, logging) => {
             logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
             logging.AddFile(hostingContext.Configuration.GetSection("Logging"));
         })
        .UseWindowsService();
}

EDIT EDIT: I am attempting to run this on a Windows Server Core image if possible. I don't know if that messes with the capabilities of Worker Services.

1 Answers1

0

you should call .UseWindowsService() when configuring your host builder. The method is contained in the package Microsoft.Extensions.Hosting.WindowsServices

nellowl
  • 339
  • 3
  • 16
  • 1
    Yep, all the services are already calling .UseWindowsService() during the host builder. I'll edit the top to add in what the generalized worker started with. – johnmiller Jan 26 '22 at 15:21