7 echo >&2 "usage: $0 (start|stop|restart|test) [options]"
9 echo >&2 "$0 start/stop/restart options:"
10 echo >&2 " -d [port], --doc[=port] Documentation server (default port 9898)"
11 echo >&2 " -w [port], --workbench[=port] Workbench server (default port 9899)"
12 echo >&2 " -s [port], --sso[=port] SSO server (default port 9901)"
13 echo >&2 " -a [port], --api[=port] API server (default port 9900)"
14 echo >&2 " -k, --keep Keep servers"
15 echo >&2 " --ssh Enable SSH access to server containers"
16 echo >&2 " -h, --help Display this help and exit"
18 echo >&2 " If no options are given, the action is applied to all servers."
20 echo >&2 "$0 test [testname] [testname] ..."
21 echo >&2 " By default, all tests are run."
26 echo `docker inspect $container |grep IPAddress |cut -f4 -d\"`
29 function start_container {
31 if [[ "$1" != '' ]]; then
35 if [[ "$2" != '' ]]; then
37 args="$args --name $name"
39 if [[ "$3" != '' ]]; then
41 args="$args -v $volume"
43 if [[ "$4" != '' ]]; then
45 args="$args --link $link"
51 args="$args -e ENABLE_SSH=$ENABLE_SSH"
54 `docker ps |grep -P "$name[^/]" -q`
55 if [[ "$?" == "0" ]]; then
56 echo "You have a running container with name $name -- skipping."
60 # Remove any existing container by this name.
61 docker rm "$name" 2>/dev/null
63 echo "Starting container:"
64 echo " docker run $args $image"
65 container=`docker run $args $image`
66 if [[ "$?" != "0" ]]; then
67 echo "Unable to start container"
72 ip=$(ip_address $container )
74 echo "You can ssh into the container with:"
81 declare -a keep_volumes
83 # Initialize the global `keep_volumes' array. If any keep volumes
84 # already appear to exist (mounted volumes with a top-level "keep"
85 # directory), use them; create temporary volumes if necessary.
87 function make_keep_volumes () {
88 # Mount a keep volume if we don't already have one
89 for mountpoint in $(cut -d ' ' -f 2 /proc/mounts); do
90 if [[ -d "$mountpoint/keep" && "$mountpoint" != "/" ]]; then
91 keep_volumes+=($mountpoint)
95 # Create any keep volumes that do not yet exist.
96 while [ ${#keep_volumes[*]} -lt 2 ]
99 echo >&2 "mounting 512M tmpfs keep volume in $new_keep"
100 sudo mount -t tmpfs -o size=512M tmpfs $new_keep
102 keep_volumes+=($new_keep)
107 local start_doc=false
108 local start_sso=false
109 local start_api=false
110 local start_workbench=false
111 local start_keep=false
113 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
114 local TEMP=`getopt -o d::s::a::w::kh \
115 --long doc::,sso::,api::,workbench::,keep,help,ssh \
118 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
120 # Note the quotes around `$TEMP': they are essential!
128 "") start_doc=9898; shift 2 ;;
129 *) start_doc=$2; shift 2 ;;
134 "") start_sso=9901; shift 2 ;;
135 *) start_sso=$2; shift 2 ;;
140 "") start_api=9900; shift 2 ;;
141 *) start_api=$2; shift 2 ;;
146 "") start_workbench=9899; shift 2 ;;
147 *) start_workbench=$2; shift 2 ;;
155 # ENABLE_SSH is a global variable
170 # If no options were selected, then start all servers.
171 if [[ $start_doc == false &&
172 $start_sso == false &&
173 $start_api == false &&
174 $start_workbench == false &&
175 $start_keep == false ]]
184 if [[ $start_doc != false ]]
186 start_container "9898:80" "doc_server" '' '' "arvados/doc"
189 if [[ $start_sso != false ]]
191 start_container "9901:443" "sso_server" '' '' "arvados/sso"
194 if [[ $start_api != false ]]
196 start_container "9900:443" "api_server" '' "sso_server:sso" "arvados/api"
199 if [[ $start_workbench != false ]]
201 start_container "9899:80" "workbench_server" '' "api_server:api" "arvados/workbench"
204 if [[ $start_keep != false ]]
206 # create `keep_volumes' array with a list of keep mount points
207 # remove any stale metadata from those volumes before starting them
209 for v in ${keep_volumes[*]}
211 [ -f $v/keep/.metadata.yml ] && sudo rm $v/keep/.metadata.yml
213 start_container "25107:25107" "keep_server_0" \
214 "${keep_volumes[0]}:/dev/keep-0" \
217 start_container "25108:25107" "keep_server_1" \
218 "${keep_volumes[1]}:/dev/keep-0" \
223 if [ -d $HOME/.config/arvados ] || mkdir -p $HOME/.config/arvados
225 cat >$HOME/.config/arvados/settings.conf <<EOF
226 ARVADOS_API_HOST=$(ip_address "api_server")
227 ARVADOS_API_HOST_INSECURE=yes
228 ARVADOS_API_TOKEN=$(cat api/generated/superuser_token)
237 local stop_workbench=""
240 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
241 local TEMP=`getopt -o d::s::a::w::kh \
242 --long doc::,sso::,api::,workbench::,keep,help,ssh \
245 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
247 # Note the quotes around `$TEMP': they are essential!
254 stop_doc=doc_server ; shift 2 ;;
256 stop_sso=sso_server ; shift 2 ;;
258 stop_api=api_server ; shift 2 ;;
260 stop_workbench=workbench_server ; shift 2 ;;
262 stop_keep="keep_server_0 keep_server_1" ; shift ;;
277 # If no options were selected, then start all servers.
278 if [[ $stop_doc == "" &&
281 $stop_workbench == "" &&
287 stop_workbench=workbench_server
288 stop_keep="keep_server_0 keep_server_1"
291 docker stop $stop_doc $stop_sso $stop_api $stop_workbench $stop_keep \
299 alltests="python-sdk api"
304 for testname in $alltests
306 echo "testing $testname..."
309 do_start --api --keep --sso
310 export ARVADOS_API_HOST=$(ip_address "api_server")
311 export ARVADOS_API_HOST_INSECURE=yes
312 export ARVADOS_API_TOKEN=$(cat api/generated/superuser_token)
313 python -m unittest discover ../sdk/python
316 docker run -t -i arvados/api \
317 /usr/src/arvados/services/api/script/rake_test.sh
320 echo >&2 "unknown test $testname"