Reference
wait
Available since
- HAProxy 3.0
- HAProxy Enterprise 3.0r1
Wait for a specified interval before performing the specified command.
Description Jump to heading
The wait
command will wait for some specified interval before then performing the specified command. You could use this to collect metrics on a certain interval. This is also useful in cases where you need to wait until a server becomes removable (the server has been drained of connections) before running additional commands, such as del server
.
The syntax for the command is: wait { -h | <delay> } [<condition> [<args>...]]
.
If you do not provide any conditions, the command will simply wait for the requested delay (in default milliseconds) time before it continues processing. At this time, the only supported condition is srv-removable
which will wait until the specified server is removable.
Tip
When using socat
, be sure to extend socat
’s timeout to account for the wait time.
Examples Jump to heading
Call the show activity
command, wait 10 seconds, then call show activity
again:
nix
echo "show activity; wait 10s; show activity" | \socat -t 20 stdio tcp4-connect:127.0.0.1:9999
nix
echo "show activity; wait 10s; show activity" | \socat -t 20 stdio tcp4-connect:127.0.0.1:9999
outputtext
thread_id: 1 (1..2)date_now: 1717443564.121845uptime_now: 659.199676[...]Done.thread_id: 1 (1..2)date_now: 1717443574.123014uptime_now: 669.200845[...]
outputtext
thread_id: 1 (1..2)date_now: 1717443564.121845uptime_now: 659.199676[...]Done.thread_id: 1 (1..2)date_now: 1717443574.123014uptime_now: 669.200845[...]
Disable a server app/app1
, call shutdown sessions server
, wait for the server to be removable, and once removable, delete the server:
nix
echo "disable server app/app1; shutdown sessions server app/app1; wait 2s srv-removable app/app1; del server app/app1" | \socat stdio tcp4-connect:127.0.0.1:9999
nix
echo "disable server app/app1; shutdown sessions server app/app1; wait 2s srv-removable app/app1; del server app/app1" | \socat stdio tcp4-connect:127.0.0.1:9999
outputtext
Done.Server deleted.
outputtext
Done.Server deleted.
Here this example uses the condition srv-removable
to wait until the server is removable.
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?