gpt4 book ai didi

docker - 通知后端容器已部署

转载 作者:行者123 更新时间:2023-12-02 20:10:07 25 4
gpt4 key购买 nike

我想创建启动小型Web服务的容器。然后,我们团队的开发人员应上传包含不同服务的小型图片。然后,主后端系统使用这些服务。

我的问题是:开发人员上载新服务时,后端服务如何知道有新服务可以使用?事先,当应该使用服务X且该功能没有服务时,它仅返回一条简单消息。当上传了一项服务以执行X时,主后端应使用该服务。但是它怎么知道它在那里并且应该被使用呢?

最佳答案

您可以向小型Web服务添加一些通知。但是,当服务意外关闭或网络在短时间内关闭时,您该怎么办?您需要向客户端添加一些逻辑以刷新连接。

和docker recommends使用这种方式。

The problem of waiting for a database (for example) to be ready is really just a subset of a much larger problem of distributed systems. In production, your database could become unavailable or move hosts at any time. Your application needs to be resilient to these types of failures.

To handle this, your application should attempt to re-establish a connection to the database after a failure. If the application retries the connection, it should eventually be able to connect to the database.

The best solution is to perform this check in your application code, both at startup and whenever a connection is lost for any reason.

关于docker - 通知后端容器已部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47154586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com