加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

node.js-docker swarm服务中的Nodejs应用程序,更新无效

发布时间:2020-12-16 03:21:58 所属栏目:安全 来源:网络整理
导读:简短如何在docker swarm中更新复制的nodejs应用程序? 预期的行为:触发更新后,服务将接收某种形式的信号,例如:SIGINT或SIGTERM 实际发生的事情:什么都没有没有信号,没有更新的服务.我必须删除该服务,然后使用更新的图像再次创建它. 我正在使用dockerode更

简短如何在docker swarm中更新复制的nodejs应用程序?

预期的行为:触发更新后,服务将接收某种形式的信号,例如:SIGINT或SIGTERM

实际发生的事情:什么都没有…没有信号,没有更新的服务.我必须删除该服务,然后使用更新的图像再次创建它.

我正在使用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信号,但至少现在我可以更新服务了

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读