Create a Windows service that allows remote update

Source: Internet
Author: User

Demo address: serverautoupdate.rar

 

Test procedure:

1) install the serverautoupdate. Server Windows Service and modify the Web service address in the configuration file to serverautoupdate. selfupdatewinserive. mgrsite.

2) Open serverautoupdate. selfupdatewinserive. mgrsite and select a service. You can see that an instance has been registered and upload a file (for example, you can update the version number of serverautoupdat. servercore and then update it)

3) after a while, you can click to view the update result to see the results of the update file on the server.

 

Basic Principles:

1) To enable Windows Services to support such updates, you only need to call selfupdatemodule. Register () at onstart and call selfupdatemodule. unregister () at onstop (). (Of course, serverautoupdate. selfupdatewinserive. dll must be referenced.) When register is used, access the Web service to register the service itself and perform reverse registration when unregister is used.

2) In the serverautoupdate. selfupdatewinserive. mgrsite website, app_data maintains a list of all active Windows Services for update.

3) call a remoting service in selfupdatemodule during the update process. Push the new file in the push mode. The server is very easy to do, save the file locally, and then call process. start to enable a cmd. Run cmd to pause the current Windows Service, update the file, and start the service. (Note that the remoting service can only be one-way due to service restart ).

4) after the service is restarted, The selfupdatemodule. Register () method checks whether there are update folders in the local folder. If yes, the Web Service is called to notify the update result and delete the folder.

5) view the file to view the UPDATE results of all instances.

 

As a matter of fact, the update principle is to use process. Start to start a bat Update file. Otherwise, it is difficult to update the dependent files ".

Related Article

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.