c++ 的在线更新机制服务器应用程序

发布于 2024-09-18 09:09:10 字数 686 浏览 7 评论 0原文

找不到有关此主题的任何内容。

我有一个 Windows TCP C++ 服务器应用程序,我想不时更新它。


正如您显然了解的那样,这会带来一个问题 - 从用户的角度来看,服务器应该是 24/7 的。
更新时,还希望保留与用户当前的 TCP 连接。


我一直在考虑一个类似模块的系统,例如套接字处理模块将驻留在“sockets.dll”中,服务器的逻辑将驻留在“logic.dll”中。
采用这种方法就像打开潘多拉魔盒;
- 我将如何进行模块的实际“交换”?想象一下,X 工作线程不断将数据从一个模块发送到另一个模块 - 在交换时,我需要一种(轻且快速)的方法来停止/暂停它们;也许是信号?
- 协议版本,甚至函数签名在更新时可能会发生变化。怎么处理?
- 其他问题,例如未被注意到的逻辑错误。
- 谁知道还会出现其他问题。


除了上述问题之外,我还担心如何更新 10 台服务器?我的意思是,它们都相互连接并进行通信。
如果更新引入了协议修改,则可能会导致巨大的问题,在这种情况下,我需要整体更新整个集群(服务器);关闭整个操作?这听起来根本不对!我该怎么做?我在这里缺少哪些概念以及如何学习它/它们?


我能做些什么吗?
你会怎么办?你做过这样的事吗?
您知道解决该问题的任何机制/文章/项目/源示例/等吗?

任何宝贵的建议都将受到高度赞赏!

Couldn't find anything about this topic.

I have a Windows TCP C++ server application which I want to update from time to time.

As you obviously understand this introduces a problem - the server should be 24/7 from the users' perspective.
When updating, it is also desired to keep the current TCP connections with the users.

I've been thinking about a module-like system so for example the socket handling module would reside at "sockets.dll", the server's logic would reside in "logic.dll".
Going for this approach seems like opening Pandora's box;
- How will I make the actual "swapping" of the modules? Imagine that X worker threads keep sending data from one module to another - when swapping I'll need a (light & fast) way to halt/pause them; signals maybe?
- Protocol version, or even functions signature might change when updating. How to handle that?
- Other problems such as unnoticed logic bugs.
- Who knows kind of other issues will arise.

Besides the above I have concerns like how do I update say 10 servers? I mean, they are all connected to each other, communicating.
If the update introduces a protocol modification it might cause huge problems, and in such case I'll need to update the whole cluster (of servers) as a whole; shut-down the whole operation? That doesn't sound right, at all! How do I do that? Which concept(s) am I missing here and how do I learn it/them?

Is there anything I can do about it?
What would you do? Have you done such a thing?
Do you know of any mechanism/article/project/source-example/etc' that solves the problem?

Any valuable advice is highly appriciated!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最冷一天 2024-09-25 09:09:11

这是一个想法:

  • 旧版本下载更新并启动它。
  • 旧版本通过将新连接转发到更新版本(侦听不同的端口)来停止接受新连接。
  • 旧版本在完成连接后会关闭。
  • 新版本会检测旧版本何时退出并切换端口。

基本上,这个想法是让两个版本同时运行。

Here's an idea:

  • Old version downloads update and starts it.
  • Old version stops accepting new connections by forwarding them to the updated version (which listens on a different port).
  • Old version shuts down when it finishes with its connections.
  • New version detects when old version quits and switches ports.

Basically, the idea is to have both versions running at the same time.

谜兔 2024-09-25 09:09:11

在协议更改方面,我建议您对协议进行版本控制。在参与服务器之间的连接开始时,让发起者或接收者(我认为哪一个并不重要)宣布它理解的协议的最新版本,然后另一方以同样的方式做出响应。他们回退到他们都理解的最新版本。

是的,这意味着维护两个协议版本的代码一段时间,但是一旦您知道所有服务器都已更新并使用新协议,您就可以停用旧代码。

假设您也可以控制所有可能的客户端软件,那么您可以对您的客户端执行相同的操作。当然,如果您无法控制用户何时升级,这可能需要更长时间地维护旧协议代码。

In terms of protocol changes, I recommend you version your protocol. At the beginning of a connection between participating servers, have either the initiator or the receiver (doesn't really matter which, I think) announce the newest version of the protocol it understands, and then the other side responds in kind. They fall back to the newest version they both understand.

Yes, this means maintaining code for both protocol versions for a while, but you can retire the old code once you know all of your servers are updated and working with the new protocol.

Assuming you have control over all possible client software, as well, you can do the same with your clients. Of course, this may entail maintaining old protocol code longer, if you don't have control over when users upgrade.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文