创建自动客户端/服务器更新程序
我为我的一个应用程序创建了一个自动应用程序更新程序。这是一个由两部分组成的应用程序。第一部分是版本检查器和更新下载器。第二部分安装下载的更新(以便更新程序可以自我更新)。
这在独立应用程序上运行良好。用户没有应用程序的快捷方式,而是更新程序的快捷方式。如果更新程序找到更新,则会下载并安装该更新,然后重新启动更新程序。如果没有找到更新,则启动用户所需的应用程序。
我现在需要为客户端\服务器应用程序创建更新过程。客户端仍然可以使用与上面相同的过程。但是,服务器不能,因为某些需要更新的文件可能正在被客户端使用。我已经考虑了几天这个问题,只提出了两个想法,但我都不喜欢。
第一个想法是最简单的,在服务器重新启动时(在客户端连接之前)运行服务器更新。我知道服务器每天至少在午夜左右重新启动一次。重新启动将会硬断开仍然连接的所有客户端,因此这些文件不应再使用。
第二个想法是当服务器需要更新时在服务器上创建某种忙碌标志。当存在繁忙标志时,客户端无法运行。我看到的问题是检查标志。客户端可以在服务器设置标志的同时检查。
我应该如何进行?您将如何实施服务器更新?想法、评论、问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果并不总是有客户端连接到服务器,您可以检查更新,必要时下载它们,然后等到没有客户端连接(或下次重新启动,以先到者为准)来安装它。
如果更新优先于客户端连接(这似乎不是基于您的问题),您可以强制关闭所有连接并更新。您还可以向已连接的客户端发送消息,让他们知道为什么要断开连接。甚至可以给他们 5 分钟的时间来保存工作并在服务器重新启动之前注销。
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.