开发者

how to run a application with fault handling when windows startup

开发者 https://www.devze.com 2022-12-09 10:38 出处:网络
all. i got a wired cas开发者_开发技巧e i got two console .net applications. let say app1 and app2.

all. i got a wired cas开发者_开发技巧e 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???


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消