Consul 配置与 multiply watches

Consul config with multiply watches

我是 Hasicorp Consul 的新手。我想在 Hashicorp Consul (v.1.7.1) watches 配置文件中添加要监视的第二个服务。应该如何正确完成?

我已经尝试了几种变体,但其中 none 可以正常工作。在这种情况下,它为 service-2 服务,但忽略 service-1。

{
  "watches": [{
      "type": "service",
      "service": "service-1",
            "tag": [ "tag1","tag2","tag3"],
            "args": ["./script.sh"],
      "type": "service",
      "service": "service-2",
            "tag": [ "tag1","tag2","tag3"],
            "args": ["./script.sh"]
  }]
}

Watches 是手表规格列表,因此每个单独的手表都需要是数组中单独的 dict/hash 项。

以下配置片段应该会成功地为每个指定的服务触发监视。

{
  "watches": [
    {
      "type": "service",
      "service": "service-1",
      "tag": [
        "tag1",
        "tag2",
        "tag3"
      ],
      "args": [
        "./script.sh"
      ]
    },
    {
      "type": "service",
      "service": "service-2",
      "tag": [
        "tag1",
        "tag2",
        "tag3"
      ],
      "args": [
        "./script.sh"
      ]
    }
  ]
}