You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/08/01 13:49:21 UTC
[08/50] tinkerpop git commit: Merge branch 'tp32' into tp33
Merge branch 'tp32' into tp33
Conflicts:
gremlin-server/src/main/bin/gremlin-server.sh
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/88b6e143
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/88b6e143
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/88b6e143
Branch: refs/heads/TINKERPOP-1878
Commit: 88b6e143dd81134074c17e5fa098f03972514273
Parents: 7985106 2b045f3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 07:16:27 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 07:16:27 2018 -0400
----------------------------------------------------------------------
gremlin-server/src/main/bin/gremlin-server.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/88b6e143/gremlin-server/src/main/bin/gremlin-server.sh
----------------------------------------------------------------------
diff --cc gremlin-server/src/main/bin/gremlin-server.sh
index fec465c,06b065a..a09e10c
--- a/gremlin-server/src/main/bin/gremlin-server.sh
+++ b/gremlin-server/src/main/bin/gremlin-server.sh
@@@ -90,191 -49,14 +90,191 @@@ els
fi
# Set Java options
-if [ "$JAVA_OPTIONS" = "" ] ; then
+if [[ "$JAVA_OPTIONS" = "" ]] ; then
- JAVA_OPTIONS="-Xms32m -Xmx512m"
+ JAVA_OPTIONS="-Xms512m -Xmx4096m"
fi
-# Execute the application and return its exit code
-if [ "$1" = "-i" ]; then
- shift
- exec $JAVA -Dlog4j.configuration=conf/log4j-server.properties $JAVA_OPTIONS -cp $CP:$CLASSPATH org.apache.tinkerpop.gremlin.server.util.GremlinServerInstall "$@"
-else
- exec $JAVA -Dlog4j.configuration=conf/log4j-server.properties $JAVA_OPTIONS -cp $CP:$CLASSPATH org.apache.tinkerpop.gremlin.server.GremlinServer "$@"
-fi
+# Build Java CLASSPATH
+CP="$GREMLIN_HOME/conf/"
+CP="$CP":$( echo $GREMLIN_HOME/lib/*.jar . | sed 's/ /:/g')
+CP="$CP":$( find -L "$GREMLIN_HOME"/ext -mindepth 1 -maxdepth 1 -type d | \
+ sort | sed 's/$/\/plugin\/*/' | tr '\n' ':' )
+
+CLASSPATH="${CLASSPATH:-}:$CP"
+
+GREMLIN_SERVER_CMD=org.apache.tinkerpop.gremlin.server.GremlinServer
+GREMLIN_INSTALL_CMD=org.apache.tinkerpop.gremlin.server.util.GremlinServerInstall
+
+
+isRunning() {
+ if [[ -r "$PID_FILE" ]] ; then
+ PID=$(cat "$PID_FILE")
+ ps -p "$PID" &> /dev/null
+ return $?
+ else
+ return 1
+ fi
+}
+
+status() {
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -gt 0 ]]; then
+ echo Server not running
+ else
+ echo Server running with PID $(cat "$PID_FILE")
+ fi
+}
+
+stop() {
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -gt 0 ]]; then
+ echo Server not running
+ rm -f "$PID_FILE"
+ else
+ kill "$PID" &> /dev/null || { echo "Unable to kill server [$PID]"; exit 1; }
+ for i in $(seq 1 60); do
+ ps -p "$PID" &> /dev/null || { echo "Server stopped [$PID]"; rm -f "$PID_FILE"; return 0; }
+ [[ $i -eq 30 ]] && kill "$PID" &> /dev/null
+ sleep 1
+ done
+ echo "Unable to kill server [$PID]";
+ exit 1;
+ fi
+}
+
+start() {
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -eq 0 ]]; then
+ echo Server already running with PID $(cat "$PID_FILE").
+ exit 1
+ fi
+
+ if [[ -z "$RUNAS" ]]; then
+
+ mkdir -p "$LOG_DIR" &>/dev/null
+ if [[ ! -d "$LOG_DIR" ]]; then
+ echo ERROR: LOG_DIR $LOG_DIR does not exist and could not be created.
+ exit 1
+ fi
+
+ mkdir -p "$PID_DIR" &>/dev/null
+ if [[ ! -d "$PID_DIR" ]]; then
+ echo ERROR: PID_DIR $PID_DIR does not exist and could not be created.
+ exit 1
+ fi
+
+ $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD "$GREMLIN_YAML" >> "$LOG_FILE" 2>&1 &
+ PID=$!
+ disown $PID
+ echo $PID > "$PID_FILE"
+ else
+
+ su -c "mkdir -p $LOG_DIR &>/dev/null" "$RUNAS"
+ if [[ ! -d "$LOG_DIR" ]]; then
+ echo ERROR: LOG_DIR $LOG_DIR does not exist and could not be created.
+ exit 1
+ fi
+
+ su -c "mkdir -p $PID_DIR &>/dev/null" "$RUNAS"
+ if [[ ! -d "$PID_DIR" ]]; then
+ echo ERROR: PID_DIR $PID_DIR does not exist and could not be created.
+ exit 1
+ fi
+
+ su -c "$JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD \"$GREMLIN_YAML\" >> \"$LOG_FILE\" 2>&1 & echo \$! " "$RUNAS" > "$PID_FILE"
+ chown "$RUNAS" "$PID_FILE"
+ fi
+
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -eq 0 ]]; then
+ echo Server started $(cat "$PID_FILE").
+ exit 0
+ else
+ echo Server failed
+ exit 1
+ fi
+
+}
+
+startForeground() {
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -eq 0 ]]; then
+ echo Server already running with PID $(cat "$PID_FILE").
+ exit 1
+ fi
+
+ if [[ -z "$RUNAS" ]]; then
+ $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD "$GREMLIN_YAML"
+ exit 0
+ else
+ echo Starting in foreground not supported with RUNAS
+ exit 1
+ fi
+
+}
+
+install() {
+
+ isRunning
+ RUNNING=$?
+ if [[ $RUNNING -eq 0 ]]; then
+ echo Server must be stopped before installing.
+ exit 1
+ fi
+
+ echo Installing dependency $@
+
+ DEPS="$@"
+ if [[ -z "$RUNAS" ]]; then
+ $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_INSTALL_CMD $DEPS
+ else
+ su -c "$JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_INSTALL_CMD $DEPS " "$RUNAS"
+ fi
+
+}
+
+case "$1" in
+ status)
+ status
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ -i)
+ shift
+ echo "Redirecting to 'install $@' (-i will be removed in a future release)"
+ install "$@"
+ ;;
+ install)
+ shift
+ install "$@"
+ ;;
+ console)
+ startForeground
+ ;;
+ *)
+ if [[ -n "$1" ]] ; then
+ if [[ -r "$1" ]]; then
+ GREMLIN_YAML="$1"
+ startForeground
+ elif [[ -r "$GREMLIN_HOME/$1" ]] ; then
+ GREMLIN_YAML="$GREMLIN_HOME/$1"
+ startForeground
+ fi
+ echo Configuration file not found.
+ fi
+ echo "Usage: $0 {start|stop|restart|status|console|install <group> <artifact> <version>|<conf file>}"; exit 1;
+ ;;
+esac