-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·74 lines (57 loc) · 1.46 KB
/
run.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -m
# Check if we find the HOST ip address from the framework, otherwise find gateway ip address via route info
if [ "$HOST" != "" ]; then
ip=$HOST
else
# Find gateway ip address
ip=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
fi
# Check if we receive a PORT0 from the framework
if [ "$PORT0" != "" ]; then
port=$PORT0
else
# Use standard port
port="27017"
fi
# Check if we receive a CONTAINER_PATH from the framework
if [ "$CONTAINER_PATH" != "" ]; then
relative_path=$CONTAINER_PATH
else
# Use standard relative path
relative_path="data"
fi
# Configure storage engine
cmd="mongod --storageEngine $STORAGE_ENGINE"
# Configure bind ip address
cmd="$cmd --bind_ip $ip"
# Configure port
cmd="$cmd --port $port"
# Configure journaling
if [ "$JOURNALING" == "no" ]; then
cmd="$cmd --nojournal"
fi
# Configure OpLog
if [ "$OPLOG_SIZE" != "" ]; then
cmd="$cmd --oplogSize $OPLOG_SIZE"
fi
# Configure ReplicaSet
if [ "$REPLICA_SET" != "" ]; then
cmd="$cmd --replSet $REPLICA_SET"
fi
# Set data directory
export DATA_PATH=$MESOS_SANDBOX/$relative_path/db
mkdir -p $DATA_PATH
cmd="$cmd --dbpath $DATA_PATH"
# Set log directory
export LOG_PATH=$MESOS_SANDBOX/$relative_path/logs
mkdir -p $LOG_PATH
cmd="$cmd --logpath $LOG_PATH/mongodb.log"
# Output the environment for debugging purposes
env
# Output the current configuration
echo $cmd
# Run MongoDB with the above-created parameters
eval $cmd &
# Run in foreground
fg