Idea of Automatic Software Update

Source: Internet
Author: User

1 Preface

For a long time, the majority of programmers have been arguing over whether to use Client/Server or browser/server structures. Among these arguments, C/S structures have poor program maintainability and difficult arrangement, the upgrade is inconvenient, and the high maintenance cost is a very important factor. Many enterprise users give up using C/S for this reason. However, when an application must use the C/S structure to implement its functions well, how can we solve the problem of client deployment and automatic upgrade? The deployment is simple. You only need to click the installer. The difficulty is that automatic upgrade can be implemented whenever a new version is released. We hope to develop a reusable automatic upgrade system unrelated to specific applications. The following describes how to implement a reusable automatic upgrade System Based on the well data center project undertaken in the work.
2. Difficulties in automatic software upgrade
First, in order to find updates on the remote server, the application must have a way to query the network, which requires network programming and simple protocol for communications between the application and the server.
The second is download. It seems that you do not need to consider the Internet of Things, but you need to consider downloading the files requested by the user and downloading large files without the user's consent. The friendly automatic update application will use the remaining bandwidth to download updates. This sounds simple, but it is a technical problem. Fortunately, there is a solution.
The third factor is the process of replacing the original application with the new application. This problem is interesting because it requires that you delete yourself from the system during code execution. There are multiple ways to implement this function, in this article, we mainly use the date number of the new and old versions to replace the new version of the application.
3 principle of automatic online software upgrade
Write two programs, one is the main program; the other is the Upgrade Program; all the upgrade tasks are completed by the Upgrade Program.
3. 1. Start the Upgrade Program, connect the Upgrade Program to the website, and download the new main program (including the supported library files, xml configuration documents, and so on) to the Temporary Folder;
. The Upgrade Program obtains the update date, version number, or file size of the new version program in the XML configuration file on the server;
3. 3. the upgrade program obtains the latest update date, version number, or file size of the original client application, and compares the two. if the date of the Upgrade Program is found to be later than the latest date of the original program, the system prompts the user whether to upgrade the current version, or compares the existing version with the latest version. If the latest version is found, the system prompts the user whether to upgrade the version. Other attributes, such as the file size, are also used for comparison, if the file size of the Upgrade Program is greater than that of the old version, the user is prompted to upgrade the program. This article mainly uses the updated date number of the new and old versions to prompt users to upgrade.
3. 4. If the user chooses to upgrade, the system obtains the list of downloaded files and starts to download documents in batches;
. The Upgrade Program checks whether the old master program is active. if the activity is active, the old master program is disabled;
3. 6. Delete the old main program and copy the files in the Temporary Folder to the corresponding location;
. Check the status of the master program. If the status is active, start the new master program;
. Close the Upgrade Program and complete the upgrade.
4. Key Steps for online upgrade
Here, I mainly use date information to check whether the upgraded version needs to be downloaded.
4.1 prepare an xml configuration file
The name is autoupdater. xml. It serves as an upgrade template and displays the information to be upgraded.
<? XML version = "1.0" encoding = "gb2312"?> // XML version number
<Autoupdater>
<Urladdres url = "http: // 192.168.198.113/vbroker/log/"/> // URL of the server where the file is updated

<Updateinfo>
<Updatetime date = "2005-02-02"/> // update date of the update File
<Version num = "1.0.0.1"/> // version of the update File
</Updateinfo>
<Updatefilelist> // list of update files
<Updatefile filename = "aa.txt"/> // three files must be upgraded.
<Updatefile filename = "vb40.rar"/>
<Updatefile filename = "VB4-1.CAB"/>
</Updatefilelist>
<Restartapp>
<Restart allow = "yes"/> // You can restart the application.
<Appname name = "tims.exe"/> // name of the started Application
</Restartapp>
</Autoupdater>
From the above XML document you can know that the upgrade document server address, upgrade document update date, the list of files to be upgraded, a total of three files need to be upgraded: aa.txt0000vb40.rar, VB4-1.CAB. And whether the application can be restarted and the name of the application to be restarted.
4.2 obtain the last update date of the client application and server upgrade Program
4.3 comparison date
The last update date of the client application is compared with the last update date of the server upgrade program. If the former is greater than the latter, it is not updated. If the former is smaller than the latter, the list of downloaded files is obtained through dynamic arrays to start downloading files.
4.4 detection and upgrade
The upgrade program checks whether the old master program is active. If it is active, it closes the old master program. It deletes the old master program and copies the files in the Temporary Folder to the corresponding location. If the Temporary Folder contains files with the same name as the files in the application directory, delete the files in the application directory. Check the status of the main program. If the status is active, then start the new main program.
At this point, the entire system is automatically updated, the process is simple, and the performance is efficient. It can be used for automatic updates of any front-end application software.

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.