Introduction
The watchdog process monitors and revives another application, should there be a failure. This can be used as a simple recovery technique to ensure application availability in critical environments. The WatchdogLib
contains all the necessary utilities to implement and integrate a simple watchdog to your .NET applications.
Background
This post is about implementing a simple Watchdog
application to revive another application. I was responsible for a mission-critical application that should run on a Windows POS device and I had to ensure the availability of that application throughout the operation time. For this, a Watchdog
application was introduced.
A simple Watchdog
application monitors another application process periodically and revives the monitored application if its process gets terminated due to a system failure. The monitored application should also monitor the Watchdog
application and awaken it if required. Additionally, the Watchdog
can be used to detect application hangs or freezes. This can be accomplished by using a heartbeat mechanism between the monitored and Watchdog
applications.
Using the Code
The WatchdogLib
has two main classes:
ApplicationWatcher
(the watchdog
)
WatchdogWatcher
(the watchdog
's watchdog
)
Using the ApplicationWatcher
ApplicationWatcher applicationWatcher = new ApplicationWatcher("MonitoredApplication", "WatchDog", 5000);
The ApplicationWatcher
class is the actual watchdog
. The ApplicationWatcher
constructor takes in the monitored application name, watchdog
application name and the preferred monitoring interval and initiates the watchdog
process.
Using the WatchdogWatcher
WatchdogWatcher watchdogWatcher =
new WatchdogWatcher("WatchDog", "WatchDog.exe", watchDogMonitorInterval);
The WatchdogWatcher
class is integrated with the monitored application and it is responsible for observing the watchdog
. The WatchdogWatcher
constructor takes in the watchdog
application name, watchdog
executable path name and the preferred monitoring interval and initiates the watchdog
watcher.
History
- Initial version(v 1.0.0.0) of the
WatchdogLib
added