RandomSec/gridworks
Stefano Mazzocchi 1343162a75 major rewrite of the foundation:
- de-maveniziation (uses the same code that Acre uses to drive jetty directly)
 - removed all dependencies on external javascript code (jquery and suggest) by making a local copy (this makes gridworks totally self-serving, meaning that you can use it even if you don't have any internet connectivity)
 - fixed a NPE when the servlet is shutdown before any project is loaded
 - found a way to spawn a browser directly from the java code (untested in windows)
 - added two ant tasks to generate windows and macosx stand-alone binaries (unused just yet)

To run, just type "./gridworks run" at the command line


git-svn-id: http://google-refine.googlecode.com/svn/trunk@65 7d457c2a-affb-35e4-300a-418c747d4874
2010-02-07 23:15:50 +00:00

174 lines
3.8 KiB
Bash
Executable File

#!/bin/sh
##########################################################
# Gridworks Control System #
##########################################################
fail() {
cat <<EOF
ERROR: $1
Usage: $0 [options] <action>
-h for more details
EOF
exit 1
}
usage() {
cat <<EOF
Usage: $0 [options] <action>
where [options] include:
-h print this message and exit
-p <port> the port that gridworks will listen to
default: 3333
-i <interface> the host interface gridworks should bind to
default: 127.0.0.1
-w <path> path to the webapp
default: src/main/webapp
-d enable JVM debugging (on port 8000)
-x enable JMX monitoring (for jconsole)
and <action> is one of
build ..... Build Gridworks
run ....... Run Gridworks
EOF
exit 0
}
add_option() {
OPTS="$OPTS $1"
}
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
}
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 -------------
[ $# -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 ------------------------------------------
while [ $# -ne 0 ] ; do
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;;
esac
done
ACTION=$1; shift
# ----- Verify and Set Required Environment Variables -------------------------
if [ "$JAVA_OPTIONS" == "" ] ; then
JAVA_OPTIONS="-Xms256M -Xmx1024M"
fi
add_option "$JAVA_OPTIONS"
if [ "$GRIDWORKS_PORT" == "" ] ; then
GRIDWORKS_PORT="3333"
fi
add_option "-Dgridworks.port=$GRIDWORKS_PORT"
if [ "$GRIDWORKS_HOST" == "" ] ; then
GRIDWORKS_HOST="127.0.0.1"
fi
add_option "-Dgridworks.host=$GRIDWORKS_HOST"
if [ "$GRIDWORKS_WEBAPP" == "" ] ; then
GRIDWORKS_WEBAPP="src/main/webapp"
fi
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 --------------------------------------------
case "$ACTION" in
build)
build;;
run)
run;;
*)
usage; ;;
esac