forked from heavyai/heavydb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startmapd
executable file
·102 lines (86 loc) · 2.68 KB
/
startmapd
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -e
trap 'trap - SIGTERM && kill -- -$$' SIGINT SIGTERM EXIT
MAPD_TCP_PORT=${MAPD_TCP_PORT:=9091}
MAPD_HTTP_PORT=${MAPD_HTTP_PORT:=9090}
MAPD_WEB_PORT=${MAPD_WEB_PORT:=9092}
MAPD_CALCITE_PORT=${MAPD_CALCITE_PORT:=9093}
MAPD_DATA=${MAPD_DATA:="data"}
while (( $# )); do
case "$1" in
--read-only)
RO="--read-only" ;;
--base-port)
shift
MAPD_WEB_PORT=$1
MAPD_TCP_PORT=$(($MAPD_WEB_PORT-1))
MAPD_HTTP_PORT=$(($MAPD_WEB_PORT-2))
MAPD_CALCITE_PORT=$(($MAPD_WEB_PORT+1))
;;
--data)
shift
MAPD_DATA=$1
;;
--enable-https)
HTTPS="--enable-https" ;;
--cert)
shift
HTTPS_CERT="--cert $1" ;;
--key)
shift
HTTPS_KEY="--key $1" ;;
--non-interactive)
NON_INTERACTIVE=true ;;
--verbose)
VERBOSE="--verbose" ;;
*)
break ;;
esac
shift
done
echo "Backend TCP: localhost:${MAPD_TCP_PORT}"
echo "Backend HTTP: localhost:${MAPD_HTTP_PORT}"
echo "Frontend Web: localhost:${MAPD_WEB_PORT}"
echo "Calcite TCP: localhost:${MAPD_CALCITE_PORT}"
if [ ! -d $MAPD_DATA/mapd_data ]; then
mkdir -p $MAPD_DATA
./bin/initdb -f --data $MAPD_DATA
if [ ! "$NON_INTERACTIVE" = true ]; then
echo "Download and insert sample data? Y/n"
read choice
if [ -z "$choice" ]; then choice="Y"; fi
case $choice in
[yY]* )
INSERT_SAMPLE_DATA=true;;
esac
fi
fi
./bin/mapd_server $MAPD_DATA $RO --port $MAPD_TCP_PORT --http-port $MAPD_HTTP_PORT --calcite-port $MAPD_CALCITE_PORT $* &
MAPDPID=$!
if [ "$INSERT_SAMPLE_DATA" = true ]; then
echo "- mapd_server started"
echo "- sleeping for 5s while server starts"
sleep 5
if [ ! "$NON_INTERACTIVE" = true ]; then
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "$DIR/insert_sample_data"
fi
fi
if [ -d frontend ] && [ -e ./bin/mapd_web_server ]; then
./bin/mapd_web_server $RO --port $MAPD_WEB_PORT --backend-url "http://localhost:${MAPD_HTTP_PORT}" --data $MAPD_DATA $HTTPS $HTTPS_CERT $HTTPS_KEY $VERBOSE &
if [ ! -z "$HTTPS" ] ; then
MAPDFRONTEND="https://localhost:${MAPD_WEB_PORT}"
else
MAPDFRONTEND="http://localhost:${MAPD_WEB_PORT}"
fi
echo "- sleeping for 5s while server starts"
sleep 5
if hash open 2>/dev/null; then
open "$MAPDFRONTEND" 2> /dev/null || true
elif hash xdg-open 2>/dev/null; then
xdg-open "$MAPDFRONTEND" 2> /dev/null || true
else
echo "Navigate to: $MAPDFRONTEND"
fi
fi
wait $MAPDPID