gpt4 book ai didi

node.js - nodejs在docker swarm服务中的应用,update没有效果

转载 作者:搜寻专家 更新时间:2023-10-31 23:50:07 25 4
gpt4 key购买 nike

短小精悍; 如何在 docker swarm 中更新复制的 nodejs 应用程序?

预期行为:触发更新后,服务会收到某种形式的信号,例如:SIGINTSIGTERM

实际发生了什么:什么都没有……没有信号,没有更新的服务。我必须删除该服务并使用更新后的图像重新创建它。

我正在使用 dockerode更新服务。 docker API 的文档,of the subject in question , 损坏了(无法展开子菜单,例如:UpdateConfig)... 很难知道我是否遗漏了任何其他规范。

如果我运行命令:docker service update <SERVICE>发生预期的行为。

最佳答案

ForceUpdate 标记必须在每次更新时加一...以便在您不对图像进行版本控制时进行更新。

    const
serviceOptions = { ... },
service = this.docker.getService(serviceName),
serviceInspected = await this.serviceInspector.inspectService(serviceName)

serviceOptions.registryAuthFrom = 'spec'
// if we do not specify the correct version, we can not update the service
serviceOptions.version = serviceInspected.Version.Index
// it's not documented by docker that we need to increase this force update flag by one, each time we attempt to update...
serviceOptions.TaskTemplate.ForceUpdate = serviceInspected.Spec.TaskTemplate.ForceUpdate + 1

const response = await service.update(serviceOptions)
response.output.Warnings && this.log.info(data.output.Warnings)

仍然无法记录来自容器的 SIGTERM 信号,但至少现在我可以更新我的服务

关于node.js - nodejs在docker swarm服务中的应用,update没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55513043/

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