Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Server 2016 IIS - Application not always running, not starting immediately, and starting twice

I have a Wep API .NET core application running through IIS on Windows Server 2016.

The app is doing a lot more than just replying to its API as it is monitoring events, etc on other services.

I have 3 problems:

  • When I start / restart the app through IIS (or when publishing an update), it doesn't do anything until there is a request coming. Then the app gets started. Is there a way to force the app to run immediately?

  • The app does a lot of background processing and I find that sometimes it stops doing anything at all. It has tasks on a timer that do not get executed, etc. If I constantly output work to the logger, this doesn't happen

  • When the app starts, it sends quite a few things to the log and during that time, I can see it start twice! It starts to display a page worth of log and then it starts again. But here is what's odd: when the app starts, there is a random 'cute name' selected so we can differentiate instances and during the original and the second startup it is the same name, so it shows that it is the same instance, but the init gets called a second time.

Is there something specific about the way apps run in an IIS container that could explain these behaviors?


After doing more search, the recommended option is to run as a service, but it's not a possibility in my case, so I still need to make a .Net Core Kestrel app with IIS as a reverse proxy.

And despite the comment below, I still don't find any good solution short of pinging the site regularly to keep it alive.

like image 333
Thomas Avatar asked Nov 18 '17 03:11

Thomas


1 Answers

On the application pool set "Start Mode" to "AlwaysRunning" and on the website, itself, set "Preload Enabled" to "true". With those two settings, the application starts immediately.

EDIT: You have to have "Application Initialization" module enabled on IIS

like image 111
Ludwo Avatar answered Oct 19 '22 21:10

Ludwo