Solved

Windows EXE/Service To Restart Faulting IIS App Pool

Posted on 2008-10-15
6
744 Views
Last Modified: 2013-12-17
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
Comment
Question by:williambailie
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:meverest
ID: 22838976
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
 

Author Comment

by:williambailie
ID: 22839104
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
 
LVL 37

Accepted Solution

by:
meverest earned 500 total points
ID: 22839267
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:williambailie
ID: 22839720
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
 
LVL 37

Expert Comment

by:meverest
ID: 22839752
Hi,

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

Cheers.
0
 

Author Comment

by:williambailie
ID: 22839783
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question