dyrnq commented on PR #8928:
URL: https://github.com/apache/apisix/pull/8928#issuecomment-1447792547

   @Fabriceli
   
   Very strange question, the consul 
<http://127.0.0.1:8500/v1/health/state/any> update have delay when consul 
service node changed
   
   when use **date && nerdctl stop nginx-1** health/state/any have 10s delay,
   when use **date && nerdctl start nginx-1** health/state/any have 2s delay,
   
   
   Create this script called consul_check_services_changes.sh
   ```bash
   #!/bin/bash
   if test ${1:-none} = "none"
   then
     echo "USAGE: $0 Consul_URL"
     echo "       Example: localhost:8500/v1/health/service/MY_SUPER_SERVICE"
     exit 1
   fi
   url_to_check=$1
   
   headers=$(mktemp)
   content=$(mktemp)
   index=0
   while true;
   do
     url="${url_to_check}?wait=5m&index=${index}&pretty=true&stale"
     curl -fs --dump-header "$headers" -o "${content}.new" "${url}" || { "echo 
Failed to query ${url}"; exit 1; }
     if test $index -ne 0
     then
       diff -u "$content" "$content.new" && echo " diff: No Differences found 
in service"
     fi
     index=$(grep "X-Consul-Index" "$headers" | sed 
's/[^0-9]*\([0-9][0-9]*\)[^0-9]*/\1/g')
     mv "$content.new" "$content"
     printf "X-Consul-Index: $index at $(date) \b"
   done
   ```
   ```bash
   ./consul_check_services_changes.sh http://127.0.0.1:8500/v1/health/state/any
   ```
   
   If /health/state/any change has deplay it can not use to for comparison 
index change.I'm looking for a solution
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to