[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

Windows EXE/Service To Restart Faulting IIS App Pool

Hi

I am looking for guidance on creating a C# windows application to detect a web application is causing continuous faults, and to recycle/restart the appropriate application pool accordingly.

Ideally, I would like to be able to detect whether or not an application pool is running or not, then enable rapid-fail protection so that as soon as the app pool shuts down, this application can restart it.

If this isn't possible, I can write something to detect the errors coming in, and then recycle the appropriate app pool.

I have no idea how to get access to the application pools programmatically, or how to identify them as associated with a particular website

Your help is really appreciated

0
williambailie
Asked:
williambailie
  • 3
  • 3
1 Solution
 
meverestCommented:
Hi,

Would it not be a better idea to fix the fault application/s?

when you enable rapid fail protection to shut down the WP, IIS should automatically restart it.

from: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5a6d38da-37d8-4d56-b6bd-1a2cbca59a57.mspx

"The WWW service detects the loss of communication and initiates the appropriate actions, typically sending an error or warning to the event log and then restarting the worker process"
0
 
williambailieAuthor Commented:
It restarts the worker process, but the web site remains stopped in IIS. Sorry, I don't think I was very clear in my question

The error is very hard to replicate, and therefore track down, and it seems to happen in only one instance of the web application, which is configured identically to a few other instances for other clients.

Also, we have our own error logging system for the application, which we can access to see if the application is faulting consistently.

So the two solutions to this issue are:

1. The ability to restart IIS worker processes programatically
2. The ability to start a website in IIS that is stopped, again programmatically.

The first instance is us having detected the faulting application, and restarting the worker process. Note, we don't want to restart IIS entirely, as there are other perfectly functioning web applications running.

In the second instance, it would be helpful to able to tell if the related IIS worker process is running,  but not essential

Any ideas? If these aren't possible, it's ok. We are considering rebuilding this application from scratch to see if that fixes it
0
 
meverestCommented:
is the web site stopped?  or the app pool?

You might use scheduler to run this every 1 minute or so:

cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs START_SERVER W3SVC/AppPools/DefaultAppPool

to start the app pool (replace 'DefaultAppPool' with the relevant apppool name) or to start a web site:

cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs START_SERVER W3SVC/1

as before, replace '1' with the web site ID.

if the server is already running, there should be no effect.  if it is stopped, this will get it running again.

it is a nasty botch, but *anything* except for fixing the underlying problem is no more than a sorry patch-up.

Cheers.
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
williambailieAuthor Commented:
Exactly, I agree it is a patch job, but this site cannot be down for very long, and it's getting annoying having to fix it at 1am on Sunday mornings. We're going to try one more thing this weekend to see if it remedies the problem, but if not, we'll have to go for this

I assume there is a STOP_SERVER command also?
0
 
meverestCommented:
Hi,

umm, yes: there is a stop_server option.... but.... WHY!??! ;-)

Cheers.
0
 
williambailieAuthor Commented:
Haha, to force a 'restart' if needed, so calling a stop, then start.

Thanks for your help meverest. It is much appreciated
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now