开发者

Creating an automatic client/server updater

开发者 https://www.devze.com 2023-01-31 07:32 出处:网络
I have created an automatic application updater for开发者_如何学运维 one of my applications.It is a two part application.The first piece is a version checker and update downloader.The second piece ins

I have created an automatic application updater for开发者_如何学运维 one of my applications. It is a two part application. The first piece is a version checker and update downloader. The second piece installs the downloaded update (so that the updater can be self updating).

This has worked well on standalone applications. Instead of the user having a shortcut to the application, they have a shortcut to the updater. If the updater finds an update, the update is downloaded, installed, and then the updater is restarted. If no update is found, the user desired application is stared.

I am now required to create an update procedure for a client\server application. The client side can still use the same process as above. However, the server cannot because some of the files that will need updated may be in use by the client. I've thought about this for a couple days now and have only came up with two ideas, of which I like neither.

The first idea is the simplest, run the server update upon server restart (before clients connect). I know the server restarts at least once a day, around midnight. The restart would do a hard disconnect of any clients still connected, so the files shouldn't be in use any longer.

The second idea is to create some kind of busy flag on the server when it needs to update. While the busy flag is present, the clients cannot be ran. The problem I see with it, is checking the flag. The client could check at the same time the server is setting the flag.

How should I proceed? How would you implement the server updates? Ideas, comments, questions?


If there's not always clients connected to the server, you could check for updates, download them if necessary and then wait until no clients are connected (or the next restart, whichever comes first) to install it.

If the update takes priority over the client connections (which it doesn't seem to based on your question) you could just force close all the connections and update. You could also send a message to the connected clients to let them know why they're about to be disconnected. Perhaps even give them a 5 minute window to save their work and log out before the server restarts.

0

精彩评论

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

关注公众号