?
Solved

Windows EXE/Service To Restart Faulting IIS App Pool

Posted on 2008-10-15
6
Medium Priority
?
755 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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