如何让saltstack等待200 OK?

时间:2015-05-14 08:37:58

标签: salt-stack

我有以下状态:

healthy:
  cmd.run:
    - name: echo 'True'
    - onlyif: "curl -I http://127.0.0.1:{{ port }} 2>/dev/null | head -n 1 | awk '$2 ~ /200/ { print \"True\" }"
    - require:
      - docker: running

问题是它只检查一次然后退出,我如何使它等待一定的超时,直到实际获得200否则退出?

1 个答案:

答案 0 :(得分:0)

while $(curl -I http://localhost:8080/ 2> /dev/null | awk '/200 OK/
 { exit 1 }'); 
do count=$(expr $count + 1); sleep 1; [ "$count" -ge "60" ] && exit 1; done