|
I have a program I am running on a Windows 2003 server under a VPS (Virtual Private Server). For some reason, the program will simply stop running. This happens infrequently. I know one reason is that the underlying hardware is rebooted and the VPS is not started properly. I can log in remotely via RDP (Remote Desktop) and restart but this is a manual process which is inconsistent with running a 24/7 service. I have been taking statistics on two different services and this appears to occur on both. Maybe there is some fundamental problem but in the meantime, I want an automatic restart. This posting describes how I implemented a restart. On a spare Windows computer, I monitor the sites with a free program called Integrio Uptime Scout. Every 5 minutes, I check both sites via an http url. If the site respones with a known response, the site is up. Otherwise it is down. 
You have to set up the email by clicking the Email settings button. In the dialog which comes up, click the Change texts button to customize the message. By default, the message will do parameter substitution so that you can tell which server is down. You will need to use this information if you are monitoring more than one server. Each server is set up with a url and phrase to verify: 
I did not have any success with the Text option and use the Regular expression instead. As long as the phrase you are testing for does not have any speciial (i.e. puctuation) characters, the phrase you are looking and the Regular expression are identical. Before we leave this screen, notice that you can run a command on server fail. If we were checking a single server, we would want to use this option. However, we need to run a different command for each server. In our case, we previously wrote custom software which runs commands based on parsed emails. Some email clients allow for writing rules or filters which do the same thing: run a command based on the contents of an email. You will have to customize this step to your own situation. If you cannot do that, you will be restricted to a single server and using the Integrio screen above. Here is a typical command file that we want to run: 
We start an RDP file (below) to connect to a remote desktop session. The Ping Command delays 35 seconds and then the RDP session is killed with the tskill command. The blacked out part is merely the name of the RDP file, which I happened to name for the server. OK. Now lets turn to the construction of the RDP file. 
We enter the login information to the RDP session on the General screen. We save the settings as a RDP file and use Open to recall it if we need to edit. On the Programs file, we give the path to the program we want to run on the server. Let me repeat: on the server. So the path is the path on the server. In our case, we re-run our application. If the application is already running, it exits silently. If it is not running, this step brings it back up. The other three tabs on the Remote Desktop options screen are not critical. |