views:

453

answers:

6

I need to implement a background process that runs on a remote windows server 24/7. My development environment is C#/ASP.NET 3.5. The purpose of the process is to:

  • Send reminder e-mails to employees and customers at appropriate times (say 5:00PM on the day before a job is scheduled)
  • Query and save GPS coordinates of employees when they are supposed to be out on jobs so that I can later verify that their positions were where they were supposed to be.

If the process fails (which it probably will, especially when updates are added), I need for it to be restarted immediately (or within just a few minutes) as I would have very serious problems if this process failed to send a notification, log a GPS coordinate, or any of the other tasks its meant to perform.

+3  A: 

You need a Windows Service. You can do non-visual iterative operations in windows services.

this. __curious_geek
Could you explain how to cause the service to automatically restart?
DOK
A: 

As well as being a service, you might want to run on a cluster, and make your service known to the cluster management software.

ChrisW
+2  A: 

Another alternative is to create a normal application and run it on a schedule. Your application is run at certain times a day to perform its actions, depending on how often you need to log GPS coordinates and send reports. If your service doesn't need to run constantly this is usually the recommended approach, as services are supposed to be limited to always-on applications.

Will
+1  A: 

You can create Windows Service (server programming on Windows) or use scheduler to periodically execute a task.

Depending on the requirements for the high availability, program can be installed on a fail-over cluster where there will be other server (passive node) started and quietly waiting as a hot-backup if the first (active node) dies. This is wide topic. Start with High availablity on Wikipedia.

Matej
+7  A: 
Peter Stuer
+1  A: 

In my experience if you need to run something 24x7 you need to have (one or more) watchdog process to verify that your service(s) are running correctly. Just relying on the normal service framework cannot guarantee that the program is working correctly - even if it looks like it is running. The watchdog program (which also is a service) can query the service automatically e.g. posting messages checking response times, querying for statistics and so on - when it detects problems it can restart the service (or do some other fail-recovery)

The reason for having a watchdog program as opposed to just rely on user queries to detect errors is that it can be done automatically. This is the preferred method because it allows for a proactive detection.

Anders K.