|
|
@@ -14,6 +14,8 @@ I’m coming across having to write the same shell script bits occasionally, and |
|
|
|
|
|
|
|
Wait for a particular URL to be available using `curl`. Wait `$duration` seconds between attempts, try `$iterations` times. Defaults to `1` seconds and `3` times. |
|
|
|
|
|
|
|
Requires `bash`. |
|
|
|
|
|
|
|
Signature: |
|
|
|
|
|
|
|
```shell |
|
|
@@ -23,7 +25,7 @@ wait_for_url url<string> [iterations<int> duration<int>] |
|
|
|
Usage: |
|
|
|
|
|
|
|
```shell |
|
|
|
source ./wait_for_url.sh |
|
|
|
. ./wait_for_url.sh |
|
|
|
|
|
|
|
# try 3 times, 1s apart |
|
|
|
wait_for_url http://127.0.0.1:5984 |
|
|
@@ -39,6 +41,8 @@ wait_for_url http://127.0.0.1:5984 5 3 |
|
|
|
|
|
|
|
Wait for a particular PID to exit. Wait `$duration` seconds between attempts, try `$iterations` times. Defaults to `1` seconds and `3` times. |
|
|
|
|
|
|
|
Requires `bash`. |
|
|
|
|
|
|
|
Signature: |
|
|
|
|
|
|
|
```shell |
|
|
@@ -48,7 +52,7 @@ wait_for_pid_exit pid<int> [iterations<int> duration<int>] |
|
|
|
Usage: |
|
|
|
|
|
|
|
```shell |
|
|
|
source ./wait_for_pid_exit.sh |
|
|
|
. ./wait_for_pid_exit.sh |
|
|
|
|
|
|
|
# try 3 times, 1s apart |
|
|
|
wait_for_pid_exit 3618 |
|
|
@@ -74,7 +78,7 @@ Usage: |
|
|
|
|
|
|
|
```shell |
|
|
|
|
|
|
|
source ./lib |
|
|
|
. ./lib |
|
|
|
|
|
|
|
# print message, then exit |
|
|
|
error_and_exit "this did not work" |
|
|
@@ -98,17 +102,17 @@ assert_arg arg<any> |
|
|
|
Usage: |
|
|
|
|
|
|
|
```shell |
|
|
|
source ./lib.sh |
|
|
|
. ./lib.sh |
|
|
|
|
|
|
|
|
|
|
|
# fail if arg is missing |
|
|
|
function my_fun () { |
|
|
|
my_fun () { |
|
|
|
assert_arg $1 && url=$1 || error_and_exit "error 'url' missing" |
|
|
|
# now $url is available |
|
|
|
} |
|
|
|
|
|
|
|
# set arg to default value if missing |
|
|
|
function my_fun () { |
|
|
|
my_fun () { |
|
|
|
assert_arg $1 && iterations=$1 || iterations=5 |
|
|
|
# now $iterations is available |
|
|
|
} |
|
|
|