2010-02-07 06:25:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
##########################################################
|
|
|
|
# Gridworks Control System #
|
|
|
|
##########################################################
|
|
|
|
|
|
|
|
fail() {
|
|
|
|
cat <<EOF
|
2010-02-07 06:25:44 +01:00
|
|
|
ERROR: $1
|
|
|
|
Usage: $0 [options] <action>
|
|
|
|
-h for more details
|
|
|
|
EOF
|
2010-02-08 00:15:50 +01:00
|
|
|
exit 1
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
usage() {
|
2010-02-08 00:15:50 +01:00
|
|
|
cat <<EOF
|
2010-02-07 06:25:44 +01:00
|
|
|
Usage: $0 [options] <action>
|
|
|
|
where [options] include:
|
|
|
|
|
|
|
|
-h print this message and exit
|
|
|
|
|
2010-02-07 06:32:07 +01:00
|
|
|
-p <port> the port that gridworks will listen to
|
2010-02-07 06:25:44 +01:00
|
|
|
default: 3333
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
-i <interface> the host interface gridworks should bind to
|
|
|
|
default: 127.0.0.1
|
|
|
|
|
|
|
|
-w <path> path to the webapp
|
|
|
|
default: src/main/webapp
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
-d enable JVM debugging (on port 8000)
|
|
|
|
|
|
|
|
-x enable JMX monitoring (for jconsole)
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
and <action> is one of
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
build ..... Build Gridworks
|
|
|
|
run ....... Run Gridworks
|
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
EOF
|
2010-02-08 00:15:50 +01:00
|
|
|
exit 0
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option() {
|
|
|
|
OPTS="$OPTS $1"
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
OPTS="$GRIDWORKS_OPTS"
|
|
|
|
|
|
|
|
# ----- actions -------------------------------------------------
|
|
|
|
|
|
|
|
build() {
|
|
|
|
if [ ! -d $GRIDWORKS_BUILD_DIR ] ; then
|
|
|
|
mkdir $GRIDWORKS_BUILD_DIR || exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ANT=`which ant`
|
|
|
|
if [ "$ANT" = "" ] ; then
|
|
|
|
ANT_TAR=`ls thirdparty | grep apache-ant`
|
|
|
|
ANT_DIR="$GRIDWORKS_BUILD_DIR/ant"
|
|
|
|
ANT="$ANT_DIR/bin/ant"
|
|
|
|
if [ ! -d $ANT_DIR ] ; then
|
|
|
|
tar xzf $ANT_TAR -C $BUILD_DIR || exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
$ANT -f build.xml compile || exit 1
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
run() {
|
|
|
|
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then
|
|
|
|
build
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_LIB_DIR/*.jar"
|
|
|
|
|
|
|
|
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
|
|
|
|
|
|
|
|
echo "Starting Gridworks at 'http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/'"
|
|
|
|
echo ""
|
|
|
|
#echo "$RUN_CMD"
|
|
|
|
#echo ""
|
|
|
|
|
|
|
|
exec $RUN_CMD
|
|
|
|
}
|
|
|
|
|
|
|
|
# ----- We called without arguments print the usage -------------
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
[ $# -gt 0 ] || usage
|
|
|
|
|
|
|
|
# ----- Normalize the current directory -------------------------
|
|
|
|
|
|
|
|
cd `dirname $0`
|
|
|
|
|
|
|
|
# ----- Make sure there is a java environment installed -------------------------
|
|
|
|
|
|
|
|
if [ ! -z "$JAVA_HOME" ] ; then
|
|
|
|
JAVA="$JAVA_HOME/bin/java"
|
|
|
|
else
|
|
|
|
JAVA=`which java`
|
|
|
|
if [ -z "$JAVA" ] ; then
|
|
|
|
system=`uname`
|
|
|
|
|
|
|
|
if [ "$system" = 'Darwin' ] ; then
|
|
|
|
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
|
|
|
|
else
|
|
|
|
echo "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ----- Parse the command line args ------------------------------------------
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
while [ $# -ne 0 ] ; do
|
2010-02-08 00:15:50 +01:00
|
|
|
case "$1" in
|
|
|
|
-p) shift; GRIDWORKS_PORT="$1"; shift; continue;;
|
|
|
|
-i) shift; GRIDWORKS_HOST="$1"; shift; continue;;
|
|
|
|
-w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;;
|
|
|
|
-d) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;;
|
|
|
|
-x) shift; add_option '-Dcom.sun.management.jmxremote'; continue;;
|
|
|
|
-*) fail "Invalid option: $1";;
|
|
|
|
*) break;;
|
2010-02-07 06:25:44 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
ACTION=$1; shift
|
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
# ----- Verify and Set Required Environment Variables -------------------------
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$JAVA_OPTIONS" == "" ] ; then
|
2010-02-07 06:25:44 +01:00
|
|
|
JAVA_OPTIONS="-Xms256M -Xmx1024M"
|
|
|
|
fi
|
|
|
|
add_option "$JAVA_OPTIONS"
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_PORT" == "" ] ; then
|
2010-02-07 06:25:44 +01:00
|
|
|
GRIDWORKS_PORT="3333"
|
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option "-Dgridworks.port=$GRIDWORKS_PORT"
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_HOST" == "" ] ; then
|
|
|
|
GRIDWORKS_HOST="127.0.0.1"
|
|
|
|
fi
|
|
|
|
add_option "-Dgridworks.host=$GRIDWORKS_HOST"
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_WEBAPP" == "" ] ; then
|
|
|
|
GRIDWORKS_WEBAPP="src/main/webapp"
|
2010-02-07 06:25:44 +01:00
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option "-Dgridworks.webapp=$GRIDWORKS_WEBAPP"
|
|
|
|
|
|
|
|
if [ "$GRIDWORKS_BUILD_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_BUILD_DIR="build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$GRIDWORKS_LIB_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_LIB_DIR="lib"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Respond to the action given --------------------------------------------
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
case "$ACTION" in
|
2010-02-08 00:15:50 +01:00
|
|
|
build)
|
|
|
|
build;;
|
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
run)
|
2010-02-08 00:15:50 +01:00
|
|
|
run;;
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
*)
|
2010-02-08 00:15:50 +01:00
|
|
|
usage; ;;
|
2010-02-07 06:25:44 +01:00
|
|
|
esac
|