19175: Merge branch 'main' into 19175-doc-refactor-multi-host-installation
[arvados.git] / lib / boot / example.sh
1 #!/bin/bash
2
3 # Example of using `arvados-server boot` in a script. Bring up a test
4 # cluster, wait for it to come up, fetch something from its discovery
5 # doc, and shut down.
6
7 set -e -o pipefail
8
9 cleanup() {
10     set -x
11     kill ${boot_PID} ${consume_stdout_PID}
12     wait ${boot_PID} ${consume_stdout_PID} || true
13     echo >&2 "done"
14 }
15
16 coproc boot (arvados-server boot -type test -config doc/examples/config/zzzzz.yml -own-temporary-database -timeout 20m)
17 trap cleanup ERR EXIT
18
19 read controllerURL <&"${boot[0]}"
20
21 # Copy coproc's stdout to stderr, to ensure `arvados-server boot`
22 # doesn't get blocked trying to write stdout.
23 exec 7<&"${boot[0]}"; coproc consume_stdout (cat <&7 >&2)
24
25 keepwebURL=$(curl --silent --fail --insecure "${controllerURL}/discovery/v1/apis/arvados/v1/rest" | jq -r .keepWebServiceUrl)
26 echo >&2 "controller is at $controllerURL"
27 echo >&2 "keep-web is at $keepwebURL"