-
Notifications
You must be signed in to change notification settings - Fork 35
/
run-main.sh
executable file
·71 lines (60 loc) · 2.28 KB
/
run-main.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
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
SCALA_VERSION=2.10
# Figure out where the Scala framework is installed
FWDIR="$(cd `dirname $0`; pwd)"
PROJECT_NAME="mlmatrix"
if [ -z "$1" ]; then
echo "Usage: run-main.sh <class> [<args>]" >&2
exit 1
fi
ASSEMBLY_DEPS_JAR=""
if [ -e "$FWDIR"/target/scala-$SCALA_VERSION/$PROJECT_NAME-assembly-*-deps.jar ]; then
export ASSEMBLY_DEPS_JAR=`ls "$FWDIR"/target/scala-$SCALA_VERSION/$PROJECT_NAME-assembly-*-deps.jar`
fi
if [[ -z $ASSEMBLY_DEPS_JAR ]]; then
ASSEMBLY_JAR=""
if [ -e "$FWDIR"/target/scala-$SCALA_VERSION/$PROJECT_NAME-assembly-*.jar ]; then
export ASSEMBLY_JAR=`ls "$FWDIR"/target/scala-$SCALA_VERSION/$PROJECT_NAME-assembly*.jar`
fi
if [[ -z $ASSEMBLY_JAR ]]; then
echo "Failed to find assembly JAR in $FWDIR/target" >&2
echo "You need to run sbt/sbt assembly or sbt/sbt assembly-package-dependency before running this program" >&2
exit 1
fi
CLASSPATH="$FWDIR/conf:$ASSEMBLY_JAR"
else
CLASSPATH="$FWDIR/conf:$ASSEMBLY_DEPS_JAR"
CLASSPATH="$CLASSPATH:$FWDIR/target/scala-$SCALA_VERSION/classes"
fi
# Find java binary
if [ -n "${JAVA_HOME}" ]; then
RUNNER="${JAVA_HOME}/bin/java"
else
if [ `command -v java` ]; then
RUNNER="java"
else
echo "JAVA_HOME is not set" >&2
exit 1
fi
fi
# Set SPARK_MEM if it isn't already set since we also use it for this process
SPARK_MEM=${SPARK_MEM:-512m}
export SPARK_MEM
JAVA_OPTS="$JAVA_OPTS -Xms$SPARK_MEM -Xmx$SPARK_MEM ""$SPARK_JAVA_OPTS"
exec "$RUNNER" -Djava.library.path=$FWDIR/lib -cp "$CLASSPATH" $JAVA_OPTS "$@"