77 строки
1.8 KiB
Plaintext
77 строки
1.8 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
function usage() {
|
||
|
echo "Usage: $0 <server-port> <hazelcast-config-path>"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
# Print usage if incorrect number of args
|
||
|
[[ $# -ne 2 ]] && usage
|
||
|
|
||
|
bin=`dirname "$0"`
|
||
|
bin=`cd "$bin"; pwd`
|
||
|
|
||
|
SERVER_PORT=$1
|
||
|
HAZELCAST_CONF=$2
|
||
|
SERVER_CLASS_NAME="com.mozilla.bagheera.rest.Bagheera"
|
||
|
JAVA_OPTS="-Xmx1000m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC"
|
||
|
|
||
|
if [ "$BAGHEERA_USER" = "" ]; then
|
||
|
BAGHEERA_USER="$USER"
|
||
|
fi
|
||
|
|
||
|
if [ "$HADOOP_CONF" = "" ]; then
|
||
|
HADOOP_CONF="/etc/hadoop/conf"
|
||
|
fi
|
||
|
|
||
|
if [ "$HBASE_CONF" = "" ]; then
|
||
|
HBASE_CONF="/etc/hbase/conf"
|
||
|
fi
|
||
|
|
||
|
if [ -d "/var/run/bagheera" ]; then
|
||
|
PIDFILE="/var/run/bagheera/bagheera.pid"
|
||
|
else
|
||
|
PIDFILE="$bin/../bagheera.pid"
|
||
|
fi
|
||
|
|
||
|
# if this is a developer then use the main jar in the build directory
|
||
|
if [ -d $bin/../build/lib ]; then
|
||
|
MAIN_JAR_PATH="$bin/../build/lib/bagheera-*.jar"
|
||
|
if [ "$DAEMON_DETACHED" = "" ]; then
|
||
|
DAEMON_DETACHED=false
|
||
|
fi
|
||
|
else
|
||
|
MAIN_JAR_PATH="$bin/../bagheera-*.jar"
|
||
|
if [ "$DAEMON_DETACHED" = "" ]; then
|
||
|
DAEMON_DETACHED=true
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
CLASSPATH="$bin/../conf":"$HADOOP_CONF":"$HBASE_CONF"
|
||
|
# add main jar
|
||
|
for lib in `ls $MAIN_JAR_PATH`; do
|
||
|
CLASSPATH=${CLASSPATH}:$lib
|
||
|
done
|
||
|
|
||
|
# add dependency libs
|
||
|
for lib in `ls $bin/../lib/*.jar`; do
|
||
|
CLASSPATH=${CLASSPATH}:$lib
|
||
|
done
|
||
|
|
||
|
# create logs dir if it doesn't exist
|
||
|
if [ ! -d $bin/../logs ]; then
|
||
|
mkdir -p $bin/../logs
|
||
|
fi
|
||
|
|
||
|
if [ "$DAEMON_DETACHED" = false ]; then
|
||
|
java -Dhazelcast.config=$HAZELCAST_CONF -Dserver.port=$SERVER_PORT -Dbagheera.log.dir=$bin/../logs $JAVA_OPTS -cp $CLASSPATH $SERVER_CLASS_NAME
|
||
|
RETVAL=$?
|
||
|
else
|
||
|
nohup java -Dhazelcast.config=$HAZELCAST_CONF -Dserver.port=$SERVER_PORT -Dbagheera.log.dir=$bin/../logs $JAVA_OPTS -cp $CLASSPATH $SERVER_CLASS_NAME > $bin/../logs/bagheera.out 2>&1 < /dev/null &
|
||
|
PID=$!
|
||
|
RETVAL=$?
|
||
|
|
||
|
echo $PID > $PIDFILE
|
||
|
fi
|
||
|
|
||
|
exit $RETVAL
|