forked from ajwdewit/ggcmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-worker.sh
executable file
·39 lines (34 loc) · 1.26 KB
/
start-worker.sh
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
#!/bin/bash
#
# This script helps you run the GGCMI docker container easily.
# It externalizes the configuration in config.sh , and does
# some basic sanity checking for the availability of external files.
#
. config.sh
function die {
echo "Error: $1" >/dev/stderr
exit 1
}
# file should exist
[ -d "$GGCMI_INPUT_DATA_HOST" ] || die "Not a directory: $GGCMI_INPUT_DATA_HOST"
[ -d "$GGCMI_OUTPUT_DATA_HOST" ] || die "Not a directory: $GGCMI_OUTPUT_DATA_HOST"
if [ "$GGCMI_MYSQL_HOST"="$TEST_MYSQL_CONTAINER_NAME" ]; then
echo 'Using Docker test container for mysql, because $GGCMI_MYSQL_HOST==$TEST_MYSQL_CONTAINER_NAME '
./start-mysql.sh || exit 1
export LINK_TO_MYSQL_CONTAINER="--link $TEST_MYSQL_CONTAINER_NAME:$TEST_MYSQL_CONTAINER_NAME"
fi
# convert relative path to absolute, as docker requires
GGCMI_INPUT_DATA_HOST=$(readlink -e $GGCMI_INPUT_DATA_HOST)
GGCMI_OUTPUT_DATA_HOST=$(readlink -e $GGCMI_OUTPUT_DATA_HOST)
# start worker
echo 'start ggcmi worker container'
docker run -dti $LINK_TO_MYSQL_CONTAINER \
-v $GGCMI_INPUT_DATA_HOST:/opt/ggcmi-input \
-v $GGCMI_OUTPUT_DATA_HOST:/opt/ggcmi-output \
-e DB_USER=$DB_USER \
-e DB_PASS=$DB_PASS \
-e DB_HOST=$DB_HOST \
-e DB_DATABASE=$DB_DATABASE \
-e NR_OF_CPUS=$NR_OF_CPUS \
--name ggcmi \
ggcmi