Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need a way to force my application (named watchdog) to remain operative even if I close it intentionally. This application, at the same time, checks for the activity of other two applications (assistance control and data transfer). Whenever one of those two applications gets closed, watchdog is ready to make it operative once again. But when watchdog is down, none is operative anymore. How can I do that? Is there a windows service that can cope with that mission?

Thanx for your help!


Thank you all guys!

After a lot of trial and error I could finally have my watchdog application giving persistent control over the operation of 'Assistance Control' and 'Data Transfer' windows applications. It actually made no sense to have two windows applications being controlled by a third windows application, mainly because of their own nature - they do exist to provide interaction, so it is OK for someone to stop watchdog whenever he wants. That's the natural way it goes. Taking Simon's suggestion into account, I decided to pass control to a new level by developing my watchdog now as a windows service. I know this might be not the best way as the service itself is communicating with GUI-based applications, not recommended at all. I set my watchdog service to allow desktop interaction and now nothing is stopping it from staying alive, unless, of course, a mean user stops the service.

If someone ever needs persistent control like this, I think this might be a well-defined and clear solution.

share|improve this question

3 Answers 3

From your description, it sounds like you also need a monitoring system. We do this - we have a bunch of watchdog scripts, we have a single topdog script that monitors that all of the listed watchdogs are running - and we have HPOV checking every 4 hours to verify that topdog is running. If it isn't, we get an alert.

Edit - HPOV is an external monitoring system, if you didn't know. To get this level of reliability and monitoring, you need monitoring that happens from outside the business systems.

share|improve this answer

A bit of a fudge, but if your "watchdog" application is a home-grown service, you could make it log an event in the event log when it's asked to stop by the SCM. You could then setup an event trigger (see EventTriggers.exe) that re-starts the service.

share|improve this answer

The Windows Service Control Manager can restart a service if it closes unexpectedly, but it won't restart a service because the service stopped in response to a "Stop" control message. For unexpected events (like an unhandled exception) this functionality can restart your program automatically. It won't help, though, if the service is stopped by a user intentionally.

It sounds like you could write a "Watchdog Watchdog", but then you'll need a "Watchdog Watchdog Watchdog". At some point you just have to give up and assume that your software can be stopped if someone wants to.

You could use a "Scheduled Task" to periodically check to see if your watchdog program is running and restart it.

share|improve this answer
    
You don't need watchdogs all the way down - you only need two differently-named watchdogs. Watchdog A watches all of the processes you care about, plus Watchdog B. Watchdog B just watches A (if you have them both trying to restart the same service you could have other problems.) Check the Hacker's Dictionary for Friar Tuck and Robin Hood. –  mfinni Nov 22 '10 at 20:13
    
@mfinni: Race conditions nonwithstanding I'd agree. I always enjoyed that story from the New Hacker's Dictionary. Makes me wish I was in computing back then! –  Evan Anderson Nov 22 '10 at 21:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.