diff --git a/LICENSE.txt b/LICENSE.txt index 394ea2d6e..a4d044a9e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,31 @@ /* - * (c) Copyright 2010 Metaweb Technologies, Inc. All rights reserved. + * Copyright (c) 2010, Metaweb Technologies, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB + * TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * */ /* diff --git a/build.xml b/build.xml index c5dd0763f..1c9a96dc3 100644 --- a/build.xml +++ b/build.xml @@ -10,10 +10,11 @@ | NOTE: this script expects the 'build.dir' and 'dist.dir' properties to be set | when invoking it. This is done like this | - | ant -f build.xml -Dbuild.dir="/path/to/build/dir" -Ddist.dir="/path/to/dist/dir" + | ant -f build.xml -Dbuild.dir="/path/to/build/dir" -Ddist.dir="/path/to/dist/dir" -Drevision="r3934" | - | the 'gridworks' shell script does this and it's meant to be the way to invoke ant, - | so running this script directly in ant is not suggested. + | Basically, this build file is designed to be invoked by the 'gridworks' shell + | script (this makes it easy to integrate into nightly-build and continuous + | integration systems). +--> @@ -30,7 +31,8 @@ - + + @@ -100,16 +102,16 @@ - + @@ -142,58 +144,66 @@ - + - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - diff --git a/gridworks b/gridworks index 818833d5d..6c96f56f6 100755 --- a/gridworks +++ b/gridworks @@ -4,6 +4,8 @@ # Gridworks Control System # ########################################################## +# -------------- functions ------------------------------------ + fail () { cat < path to the data directory default: OS dependent + + -m max memory heap size to use + default: 1024M --debug enable JVM debugging (on port 8000) - --jmx enable JMX monitoring (for jconsole) + --jmx enable JMX monitoring (for jconsole and jvisualvm) and is one of @@ -49,8 +54,9 @@ and is one of make_dmg ........ Make MacOSX DMG distribution make_exe ........ Make Windows EXE distribution - make_cli ........ Make zip distribution to be run at command line - make_all ........ Make all distributions + make_cli ........ Make distributions to be run at command line + + dist ............ Make all distributions clean ..................... Clean compiled classes distclean ................. Remove all generated files @@ -58,24 +64,17 @@ and is one of EOF exit 1 } - + add_option() { OPTS="$OPTS $1" } - -OPTS="$GRIDWORKS_OPTS" - -# Normalize the current directory -cd `dirname $0` - -SYSTEM=`uname` - -if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then - export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" -fi - -# ----- actions ------------------------------------------------- - + +load_configs() { + cat $1 | egrep "^[A-Z]" | sed 's/^\(.*\)$/export \1/' > .$1 + . ./.$1 + rm ./.$1 +} + check_macosx() { if [ "$SYSTEM" != 'Darwin' ] ; then error "This action can only run on MacOSX" @@ -102,8 +101,7 @@ ant_prepare() { ant() { ant_prepare - echo $NUM_VERSION - $ANT -f build.xml -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Djava.options="$JAVA_OPTIONS" $1 || exit 1 + $ANT -f build.xml -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Drevision="$REVISION" $1 || exit 1 } dist_prepare() { @@ -122,23 +120,6 @@ launch4j_prepare() { cd .. } -protobuf_prepare() { - cd thirdparty - PROTOBUF_TAR=`ls | grep protobuf | grep tar.gz | grep -v svn` - PROTOBUF_DIR=`echo $PROTOBUF_TAR | sed 's/.tar.gz//'` - PROTOC="`pwd`/$PROTOBUF_DIR/bin/protoc" - if [ ! -f $PROTOC ] ; then - tar xzf $PROTOBUF_TAR -C . || exit 1 - cd $PROTOBUF_DIR - ./configure --prefix=`pwd` - make - make install - cd .. - fi - PROTOC="`pwd`/$PROTOBUF_DIR/bin/protoc" - cd .. -} - get_version() { VERSION=$1 @@ -149,7 +130,19 @@ get_version() { NUM_VERSION=`echo $VERSION | sed 's/[a-zA-Z]//g'` } -make_all() { +get_revision() { + if [ -d ".svn" ]; then + INFO=`svn info` + elif [ -d ".git" ]; then + INFO=`git svn info` + else + error "cannot obtain revision, exiting!" + fi + + REVISION=`echo $INFO | sed 's/.*Revision: /r/' | sed 's/ .*//'` +} + +dist() { make_dmg $1 make_exe $1 make_cli $1 @@ -160,23 +153,30 @@ make_exe() { dist_prepare launch4j_prepare get_version $1 + get_revision ant exe + + echo "" + echo "Built exe ZIP for version $VERSION-$REVISION" } make_cli() { - check_macosx dist_prepare - launch4j_prepare get_version $1 + get_revision ant cli + + echo "" + echo "Built cli ZIP for version $VERSION-$REVISION" } make_dmg() { check_macosx dist_prepare get_version $1 + get_revision ant bundle @@ -220,8 +220,11 @@ make_dmg() { sync hdiutil detach $DEVICE hdiutil convert "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" -format UDZO -imagekey zlib-level=9 -o "$GRIDWORKS_DIST_DIR/gridworks-$VERSION.dmg" - hdiutil internet-enable -yes "$GRIDWORKS_DIST_DIR/gridworks-$VERSION.dmg" + hdiutil internet-enable -yes "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" rm -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" + + echo "" + echo "Built DMG for version $VERSION-$REVISION" } test() { @@ -250,8 +253,10 @@ test() { run() { if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then - ant build - echo "" + if [ `ls $GRIDWORKS_LIB_DIR | grep gridworks` == "" ] ; then + ant build + echo "" + fi fi if [ "$SYSTEM" == 'Darwin' ] ; then @@ -290,6 +295,8 @@ execute() { exec $RUN_CMD $* } +# -------------------------- script ----------------------------- + # ----- We called without arguments print the usage ------------- [ $# -gt 0 ] || usage @@ -298,7 +305,21 @@ execute() { cd `dirname $0` -# ----- Make sure there is a java environment installed ------------------------- +# ----- Default values ------------------------------------------ + +OPTS="" + +SYSTEM=`uname` + +if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then + export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" +fi + +# ----- Load configurations ------------------------------------- + +load_configs gridworks.ini + +# ----- Make sure there is an appropriate java environment is available ------------- if [ ! -z "$JAVA_HOME" ] ; then JAVA="$JAVA_HOME/bin/java" @@ -327,6 +348,7 @@ while [ $# -ne 0 ] ; do -i) shift; GRIDWORKS_HOST="$1"; shift; continue;; -w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;; -d) shift; GRIDWORKS_DATA_DIR="$1"; shift; continue;; + -m) shift; GRIDWORKS_MEMORY="$1"; shift; continue;; --debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;; --jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;; -*) fail "Invalid option: $1";; @@ -339,10 +361,15 @@ ACTION=$1; shift # ----- Verify and Set Required Environment Variables ------------------------- if [ "$JAVA_OPTIONS" == "" ] ; then - JAVA_OPTIONS="-Xms256M -Xmx1024M -XX:+UseParallelGC" + JAVA_OPTIONS="" fi add_option "$JAVA_OPTIONS" +if [ "$GRIDWORKS_MEMORY" == "" ] ; then + GRIDWORKS_MEMORY="1024M" +fi +add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY" + if [ "$GRIDWORKS_PORT" == "" ] ; then GRIDWORKS_PORT="3333" fi @@ -408,9 +435,10 @@ case "$ACTION" in make_cli) make_cli $1;; - make_all) - make_all $1;; + dist) + dist $1;; *) usage; ;; + esac diff --git a/gridworks.bat b/gridworks.bat index e7f9acdcd..cfb77fdb0 100644 --- a/gridworks.bat +++ b/gridworks.bat @@ -7,7 +7,7 @@ rem Home of Java installation. rem rem JAVA_OPTIONS rem Extra options to pass to the JVM -rem +rem if "%OS%"=="Windows_NT" @setlocal if "%OS%"=="WINNT" @setlocal @@ -31,7 +31,10 @@ echo. echo /w path to the webapp echo default src\main\webapp echo. -echo /d enable JVM debugging (on port 8000) +echo /d enable JVM debugging (on port 8000) +echo. +echo /m max memory heap size to use +echo default: 1024M echo. echo /x enable JMX monitoring (for jconsole and friends) echo. @@ -39,7 +42,7 @@ echo and is one of echo. echo build ..................... Build Gridworks echo run ....................... Run Gridworks -echo. +echo. echo clean ..................... Clean compiled classes echo distclean ................. Remove all generated files echo. @@ -52,11 +55,23 @@ goto end :endUtils if not "%JAVA_HOME%" == "" goto gotJavaHome -echo You must set JAVA_HOME to point at your Java Development Kit installation +echo You must set JAVA_HOME to point at your Java Development Kit installation +echo. +echo If you don't know how to do this, follow the instructions at +echo. +echo http://bit.ly/1c2gkR +echo. + goto fail :gotJavaHome - -set OPTS=%GRIDWORKS_OPTS% + +rem --- Read ini file -------------------------------------------- + +set OPTS= + +for /f "tokens=1,2 delims==" %%a in (gridworks.ini) do ( + set %%a=%%b +) rem --- Argument parsing -------------------------------------------- @@ -67,6 +82,7 @@ if ""%1"" == ""/p"" goto arg-p if ""%1"" == ""/i"" goto arg-i if ""%1"" == ""/w"" goto arg-w if ""%1"" == ""/d"" goto arg-d +if ""%1"" == ""/m"" goto arg-m if ""%1"" == ""/x"" goto arg-x goto endArgumentParsing @@ -81,6 +97,10 @@ goto shift2loop :arg-w set GRIDWORKS_WEBAPP=%2 goto shift2loop + +:arg-m +set GRIDWORKS_MEMORY=%2 +goto shift2loop :arg-d set OPTS=%OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n @@ -100,9 +120,14 @@ goto loop rem --- Fold in Environment Vars -------------------------------------------- if not "%JAVA_OPTIONS%" == "" goto gotJavaOptions -set JAVA_OPTIONS=-Xms256M -Xmx1024M -XX:+UseLargePages -XX:+UseParallelGC +set JAVA_OPTIONS= :gotJavaOptions set OPTS=%OPTS% %JAVA_OPTIONS% + +if not "%GRIDWORKS_MEMORY%" == "" goto gotMemory +set GRIDWORKS_MEMORY=1024M +:gotMemory +set OPTS=%OPTS% -Xms256M -Xmx%GRIDWORKS_MEMORY% if not "%GRIDWORKS_PORT%" == "" goto gotPort set GRIDWORKS_PORT=3333 @@ -139,12 +164,25 @@ if ""%ACTION%"" == ""run"" goto doRun goto usage :doRun -set CLASSPATH="%GRIDWORKS_BUILD_DIR%\classes;%GRIDWORKS_LIB_DIR%\*" +set CLASSPATH="%GRIDWORKS_BUILD_DIR%\classes;%GRIDWORKS_LIB_DIR%\*" +echo %OPTS% "%JAVA_HOME%\bin\java.exe" -cp %CLASSPATH% %OPTS% -Djava.library.path=lib/native/windows com.metaweb.gridworks.Gridworks goto end -:doAnt -ant -f build.xml -Dbuild.dir="%GRIDWORKS_BUILD_DIR%" -Ddist.dir="%GRIDWORKS_DIST_DIR%" -Dversion="%VERSION%" %ACTION% +:doAnt +if not "%ANT_HOME%" == "" goto gotAntHome +echo You must have Apache Ant installed and the ANT_HOME environment variable to point to it +echo. +echo You can find a copy of ant in the "\thirdparty" folder or download it from +echo. +echo http://ant.apache.org/ +echo. +echo If you don't know how to set environment variables, follow the instructions at +echo. +echo http://bit.ly/1c2gkR +echo. +:gotAntHome +"%ANT_HOME%\bin\ant.bat" -f build.xml -Dbuild.dir="%GRIDWORKS_BUILD_DIR%" %ACTION% goto end :end diff --git a/gridworks.ini b/gridworks.ini new file mode 100644 index 000000000..d0d1ef7aa --- /dev/null +++ b/gridworks.ini @@ -0,0 +1,6 @@ +#GRIDWORKS_PORT=3333 +#GRIDWORKS_HOST=127.0.0.1 +#GRIDWORKS_MEMORY=1024M + +#JAVA_HOME="" +#JAVA_OPTIONS="-XX:+UseParallelGC -XX:+UseLargePages"