views:

27

answers:

3

hi, all. i got a wired case i got two console .net applications. let say app1 and app2.

i want both the applications run when the windows server startup (without login, my two apps will run automatically)

but there is a rules, app1 must run at least 10 minutes before app2. and any one of them crash, i want them can raise up again automatically

does anyone know how can i do this???

+1  A: 

The only acceptable way in my mind is to have a third service that acts as a watchdog and triggers when the other services would start.

This will have to be serviced by the other processes with a regular "heartbeat" in order to prevent it from closing and restarting the services that it watches.

ChrisBD
+1  A: 

start app1 setup timer. after 10 minutes elapsed start app2 and go to the state app2_launched. then use something like pid files or os shared objects to 'monitor' each other

Trickster
+1  A: 

First, if your apps must run without a user logging in, they must be services.

Now, when creating a service, you can decide how you want to respond to crashes. You can configure a service to restart in the case of a crash (see the service properties dialog).

If App1 crashes, do you have to stop App2, start App1, and then, 10 minutes later, restart App2? Or in that case, can you just restart App1 immediately?

From what you describe however, The control over start ordering appears complex enough that built in service configuration will not be sufficient, so you'll most likely need to keep that logic somewhere.

If it is ok for App1 to know about App2, you could have that logic in App1. App1 would then have 2 responsibilities (to run itself, and to manage the state of the App2 service).

On the other hand, you could have a third service that is just responsible for managing the lifecycle and health of App1 and App2 services. This is the watchdog that ChrisBD suggests.

Nader Shirazie