I have a HaProxy load balancer on front of some IIS webservers. Haproxy checks the iis apps on a specific path if they are up or in maintenance.
I would like to make a solution, where I can safely reboot a random IIS machine and then have this to trigger my iis application to:
- React to the reboot and return a certain response code (a 404 in this case) on a specific path
- Stall the host machine reboot for 15 seconds to ensure all calls have been dealt with and that haproxy has seen this 404-status code signalling an upcoming reboot of the iis server.
Is it in any way possible to do these two things?
Windows Server 2016, .Net 4.7.2
This will not work, as all calls to the IIS will return "Service unavailable" when the IIS is running the Application_End code:
protected void Application_End()
{
var log = SystemLogManager.GetLogger(GetType());
try
{
log.Warn("Ending application. Hanging for 15 seconds...");
Thread.Sleep(TimeSpan.FromSeconds(15));
log.Warn("Done end");
}
catch(Exception ex)
{
log.Error("Unexpected error in application end", ex);
}
}