-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.sh
More file actions
executable file
·51 lines (47 loc) · 2.54 KB
/
server.sh
File metadata and controls
executable file
·51 lines (47 loc) · 2.54 KB
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
#!/bin/bash
####################################################################################################
# Server Configuration #
# https://github.com/ashwin153/beaker/blob/master/beaker-server/src/main/resources/reference.conf #
####################################################################################################
PORT=9090
OPTS=""
while getopts ":hc:l:o:p:" opt; do
case $opt in
h ) echo "Usage: $0 [option...] " >&2
echo
echo " -h Displays this help message. "
echo
echo " -c Path to configuration file. "
echo " -l Path to log4j properties file. "
echo " -o Configuration overrides. "
echo " -p Port number. (9090) "
echo
exit 1
;;
c ) eval cp ${OPTARG} /beaker-server/src/main/resources/application.conf
trap 'rm /beaker-server/src/main/resources/application.conf' EXIT
;;
l ) OPTS+=" --jvm-run-jvm-options="\""-Dlog4j.configuration=file:${OPTARG}"\"
;;
o ) OPTS+=" --jvm-run-jvm-options="\""-D${OPTARG}"\"
;;
p ) PORT=${OPTARG}
;;
esac
done
HOST=$(hostname -I | cut -d' ' -f1)
OPTS+=" --jvm-run-jvm-options="\""-Dbeaker.server.address=${HOST}:${PORT}"\"
####################################################################################################
# JVM Configuration #
# https://github.com/ashwin153/beaker/blob/master/beaker-server/src/main/resources/reference.conf #
####################################################################################################
FREE=$( free -m | awk 'FNR == 2 {print $4}')
LOG2=$( echo "l($FREE)/l(2)" | bc -l )
MAX_HEAP=$(( 1 << ${LOG2%.*} ))
MIN_HEAP=$(( 1 << ${LOG2%.*} - 1 ))
OPTS+=" --jvm-run-jvm-options="\""-Xms${MIN_HEAP}M -Xmx${MAX_HEAP}M"\"
####################################################################################################
# Bootstrap Server #
# https://github.com/ashwin153/beaker/tree/master/beaker-server #
####################################################################################################
eval ./pants run beaker-server/src/main/scala:bin ${OPTS}