Score:1

Application Pool set to AlwaysRunning does not Auto Start The Hosted Service

bd flag

I have configured an pool to auto-start and never sleep. I am having problems with the auto-start. My understanding is that a thread pool worker will be started after a recycle when that happens I would assume the application entry point would be called, however, that does not seem to be working.

When the application is deployed, I see the following log entries under the "IIS AspNetCore Modeule" V2 sink.

  1. 1/28/2022 9:25:15 AM - Running job: Release
  2. 1/28/2022 9:25:28 AM - Application 'C:<path to app>' was recycled after detecting app_offline.htm.
  3. 1/28/2022 9:25:29 AM - Application 'MACHINE/WEBROOT/APPHOST//' has shutdown.
  4. 1/28/2022 9:25:33 AM - Job Release completed with result: Succeeded

Where

  1. DevOps Microservice Build - Start
  2. Recycle (build creates the app_offline)
  3. Api Shutdown
  4. DevOps Microservice Build Start - Succeeded

I am puzzled that there is not a associated api startup message such as - Application 'C:<path to app>' started successfully.

It is important to note that this a .NET Core API "microservice" that does not take any http requests. In code, the startup has this configuration.

services.AddHostedService<AuthorizationMessageConsumerService>();

and

public class AuthorizationMessageConsumerService : BackgroundService

If after every deployment, the /health endpoint is pinged then the service starts up.

I can only guess that AlwaysRunning just created a new request thread but does not call any entry point, which gets called by an incoming http request /health.

I am trying to avoid making a ping a build and deployment requirement. Are there any options or would setting up health pings on timed intervals and post deployment be the best solution?

IIS Configuration

enter image description here

Ross Bush avatar
bd flag
I am thinking that in IIS an http request is required to activate code that starts the application domain and in this case the background worker.
Score:0
bd flag

The one thing I was missing was Preload Enabled=true at the IIS application level. That will basically send in a request ton start your app after a recycle due to a deployment or anything else.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.