[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Windows EXE/Service To Restart Faulting IIS App Pool

Posted on 2008-10-15
6
Medium Priority
?
760 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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