Windows Service Auto Restart Services

Source: Internet
Author: User

Services generally can run normally, but sometimes there will be some of the phenomenon of suspended animation, such as the company has a time attendance service because of the hardware manufacturers rely on the API,

But the manufacturers API run for a period of time will be silent after the death, causing the entire service suspended animation, because this phenomenon of suspended animation is uncertain, so it is unlikely

See the fake after death manually to start.

Now I know there are two ways to solve this situation:

1. Write another service to listen to the current service "need some common data to determine whether it is suspended animation", one but found suspended animation, to restart
2. Restart using the service itself.

A. Open the Control Panel-"Management tools-" service, find the need to restart the service automatically, right click-"Properties, click on the Recovery tab," first failure (F) "," Second failure (S) "," subsequent failure (U) "is set to" Restart Service ", click OK,
    
B. The service procedure in the open-line process, the death of suspended animation, once found suspended animation, the implementation of Environment.exit (1); This will restart the service after exiting
Note: This method presupposes that the thread of suspended animation can run normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.