所以我有一个 consul check 来监视一个容器,并设计为在容器停止时变得至关重要。我想创建一个领事手表,它将在检查变得关键或几个关键响应之后运行脚本(例如,如果我的检查发送 5 个关键响应,我希望它运行脚本)。
这是用于我的工作检查的 json,以及我对我的手表可能是什么样子的猜测:
{
// this check works
"checks": [
{
"id": "docker_stuff",
"name": "curl test",
"notes": "curls the docker container",
"script": "/scripts/docker.py",
"interval": "1s"
}
],
//this watch doesn't work
"watches": [
{
"Node": "client2",
"CheckID": "docker-stuff",
"Name": "docker-stuff-watch",
"Status": "critical",
"Status_amt": "5",
"handler": "/scripts/new-docker.sh",
"Output": "container relaunched",
}
]
}
我需要对手表进行哪些更改才能使其正常工作?
我是否还需要使用领事事件来监视我的健康检查,然后触发运行我的/scripts/new-docker.sh
脚本的领事监视(事件类型)?如果是这样,那么我将如何进行领事活动来监视我的健康检查?例如,如果这是我的领事检查、监视和事件,我需要更改什么才能使其正常工作?
{
"checks": [
{
"id": "docker_stuff",
"name": "curl test",
"notes": "curls the docker container",
"script": "/scripts/docker.py",
"interval": "1s"
}
],
"watches": [
{
"type": "event",
"name": "docker-stuff-watch",
"handler": "/scripts/new-docker.sh"
}
],
"events": [
{
"Node": "client2",
"CheckID": "docker-stuff",
"Name": "docker-stuff-event",
"Status": "critical",
"Status_amt": "5",
"Output": "container relaunched",
}
]
}