-
Notifications
You must be signed in to change notification settings - Fork 0
/
scythe-admin
executable file
·58 lines (52 loc) · 2.99 KB
/
scythe-admin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
export ADMIN_COMMAND="$1"
shift
export NUM_CPUS=4
case "$ADMIN_COMMAND" in
core)
HTML="$1"
if [ -z "$HTML" ]; then
echo "scythe-admin: core: please specify your html root" >&2
exit 1
fi
if [ ! -d "$HTML" ]; then
echo "scythe-admin: core: your html root '$HTML' seems not to be a directory" >&2
exit 1
fi
dids=$(docker ps -a --filter label=scythe=core --format '{{.ID}}')
if [ ! -z "$dids" ]; then
echo "scythe-admin: core: killing old core instances..." $(docker rm -f $dids) >&2
fi
did=$(docker run -l scythe=core --name scythe-portainer -p 9000:9000 -v scythe-portainer:/data -v /var/run/docker.sock:/var/run/docker.sock -d portainer/portainer --no-auth -H unix:///var/run/docker.sock)
echo "scythe-admin: core: started container 'scythe-portainer' (docker id '$did')" >&2
did=$(docker run --network scythe -l scythe=core --name scythe-viewer -d scythe-server/viewer)
echo "scythe-admin: core: started container 'scythe-viewer' (docker id '$did')" >&2
did=$(docker run -l scythe=core --name scythe-router --network scythe -p 80:80 -v "$(realpath $HTML)":/usr/share/nginx/html:ro -d scythe-server/router)
date > "$HTML/now.txt"
echo "scythe-admin: core: started container 'scythe-router', html in '$HTML' at $(curl -s http://$(hostname)/now.txt) (docker id '$did')" >&2
rm -f "$HTML/now.txt"
;;
tester)
TESTER_ID="$1"
if [ -z "$TESTER_ID" ]; then
echo "scythe-admin: tester: please specify the tester id" >&2
exit 1
fi
export SCYTHE_LABEL="scythe=tester-${TESTER_ID}"
export SCYTHE_CONTAINER="scythe-${TESTER_ID}"
export REDIS_VOLUME="scythe-${TESTER_ID}-redis"
dids=$(docker ps -a --filter label="$SCYTHE_LABEL" --format '{{.ID}}')
if [ ! -z "$dids" ]; then
echo "scythe-admin: tester: killing old tester instances..." $(docker rm -f $dids) >&2
fi
did=$(docker run -l "$SCYTHE_LABEL" -d -v "$REDIS_VOLUME:/data" --name "${SCYTHE_CONTAINER}-redis" --network=scythe scythe-server/redis)
echo "scythe-admin: tester: started container '${SCYTHE_CONTAINER}-redis' with volume '$REDIS_VOLUME' (docker id '$did')..." 2>&1
did=$(docker run -l "$SCYTHE_LABEL" -d -e SCYTHE_REDIS_HOST="${SCYTHE_CONTAINER}-redis" --name "${SCYTHE_CONTAINER}-processor" --network=scythe scythe-server/stserver process -Nw $NUM_CPUS)
echo "scythe-admin: tester: started container '${SCYTHE_CONTAINER}-processor' (docker id '$did')..." 2>&1
did=$(docker run -l "$SCYTHE_LABEL" -d -e SCYTHE_REDIS_HOST="${SCYTHE_CONTAINER}-redis" --name "${SCYTHE_CONTAINER}-rest" --network=scythe scythe-server/stserver rest)
echo "scythe-admin: tester: started container '${SCYTHE_CONTAINER}-rest' (docker id '$did')..." 2>&1
;;
*)
echo "scythe-admin: command '$ADMIN_COMMAND' not recognized" >&2
exit 1
esac