added sysv and systemd init scripts

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/92fdf91f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/92fdf91f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/92fdf91f

Branch: refs/heads/TINKERPOP-1520
Commit: 92fdf91fc70f13e801717eb2d18924b90d0cb02b
Parents: 4334087
Author: Robert Dale <robd...@gmail.com>
Authored: Tue Sep 27 20:27:47 2016 -0400
Committer: Robert Dale <robd...@gmail.com>
Committed: Thu Nov 17 03:45:36 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 docs/src/upgrade/release-3.3.x.asciidoc         |  51 ++++++
 gremlin-server/src/main/bin/gremlin-server.conf |  24 +++
 .../src/main/bin/gremlin-server.initd           | 173 +++++++++++++++++++
 .../src/main/bin/gremlin-server.service         |  18 ++
 5 files changed, 267 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/92fdf91f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7482d3f..105d7f4 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -44,6 +44,7 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Added `gremlin-tools` and its submodule `gremlin-coverage`.
 * Removed `tryRandomCommit()` from `AbstractGremlinTest`.
 * Changed `gremlin-benchmark` system property for the report location to 
`benchmarkReportDir` for consistency.
+* Added SysV and systemd init scripts.
 
 TinkerPop 3.2.0 (Nine Inch Gremlins)
 ------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/92fdf91f/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.3.x.asciidoc 
b/docs/src/upgrade/release-3.3.x.asciidoc
index b05ccff..6bcc8e6 100644
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@ -112,3 +112,54 @@ concerned with breaking changes related to the removal of:
 Those graph providers who relied on these tests should simply remove them from 
their respective test suites.
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1235[TINKERPOP-1235]
+
+SysV and Systemd Init Scripts
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This replaces gremlin-server.sh
+
+*SysV*
+
+Certain parameters can be configured via bin/gremlin-server.conf
+
+[source,bash]
+----
+# Install
+ln -s /path/to/apache-tinkerpop-gremlin-server-x.y.z/bin/gremlin-server.initd 
/etc/init.d/gremlin-server
+
+# Systems with chkconfig/service. E.g. Fedora, Red Hat
+chkconfig --add gremlin-server
+
+# Start
+service gremlin-server start
+
+# Or call directly
+/etc/init.d/gremlin-server restart
+
+# Can even be used without installing
+./bin/gremlin-server.initd restart
+----
+
+*systemd*
+
+JAVA_HOME and JAVA_OPTIONS can be configured via bin/gremlin-server.conf
+
+[source,bash]
+----
+# Install
+cp /path/to/apache-tinkerpop-gremlin-server-x.y.z/bin/gremlin-server.service 
/etc/systemd/system/
+
+# Configure systemd template
+# Update WorkingDirectory, EnvironmentFile, ExecStart installation path 
locations
+# Check User, Group
+edit /etc/systemd/system/gremlin-server.service
+
+# Enable
+systemctl enable gremlin-server
+
+# Start
+systemctl start gremlin-server
+
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-980[TINKERPOP-980]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/92fdf91f/gremlin-server/src/main/bin/gremlin-server.conf
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/bin/gremlin-server.conf 
b/gremlin-server/src/main/bin/gremlin-server.conf
new file mode 100644
index 0000000..e38f239
--- /dev/null
+++ b/gremlin-server/src/main/bin/gremlin-server.conf
@@ -0,0 +1,24 @@
+
+# initd: debug the initd script
+#DEBUG=1
+
+# initd: gremlin server install location
+#GREMLIN_HOME=
+
+# initd: Yaml file passed to gremlin server. Path can be absolute or relative 
to GREMLIN_HOME e.g. conf/gremlin-server.yaml
+#GREMLIN_YAML=
+
+# initd: console log location
+#LOG_DIR=
+
+# initd: server PID location
+#PID_DIR=
+
+# initd: run server as user
+#RUNAS=gremlin
+
+# set java installation
+#JAVA_HOME=
+
+# set java options
+#JAVA_OPTIONS=

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/92fdf91f/gremlin-server/src/main/bin/gremlin-server.initd
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/bin/gremlin-server.initd 
b/gremlin-server/src/main/bin/gremlin-server.initd
new file mode 100755
index 0000000..1049806
--- /dev/null
+++ b/gremlin-server/src/main/bin/gremlin-server.initd
@@ -0,0 +1,173 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+### BEGIN INIT INFO
+# Provides:          gremlin-server
+# Required-Start:    $remote_fs $syslog $network
+# Required-Stop:     $remote_fs $syslog $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Gremlin Server
+# Description:       Apache Tinkerpop Gremlin Server
+# chkconfig:         2345 98 01
+### END INIT INFO
+
+[[ -n "$DEBUG" ]] && set -x
+
+SOURCE="$0"
+while [ -h "$SOURCE" ]; do
+  cd -P "$( dirname "$SOURCE" )" || exit 1
+  DIR="$(pwd)"
+  SOURCE="$(readlink "$SOURCE")"
+  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
+done
+cd -P "$( dirname "$SOURCE" )" || exit 1
+GREMLIN_BIN="$(pwd)"
+
+GREMLIN_CONF=$GREMLIN_BIN/gremlin-server.conf
+
+[[ -r $GREMLIN_CONF ]] && source $GREMLIN_CONF
+[[ -n "$DEBUG" ]] && set -x
+
+if [ -z "$GREMLIN_HOME" ]; then
+  cd ..
+  GREMLIN_HOME="$(pwd)"
+fi
+
+GREMLIN_CMD=$GREMLIN_HOME/bin/gremlin-server.sh
+
+if [ -z "$LOG_DIR" ] ; then
+  LOG_DIR="$GREMLIN_HOME/logs"
+fi
+
+if [ ! -d "$LOG_DIR" ]; then
+  echo LOG_DIR $LOG_DIR does not exist
+  exit 1
+fi
+
+if [ -z "$LOG_FILE" ]; then
+  LOG_FILE="$LOG_DIR/gremlin.log"
+fi
+
+if [ -z "$PID_DIR" ] ; then
+  PID_DIR="$GREMLIN_HOME/run"
+fi
+
+if [ ! -d "$PID_DIR" ]; then
+  echo PID_DIR $PID_DIR does not exist
+  exit 1
+fi
+
+if [ -z "$PID_FILE" ]; then
+  PID_FILE=$PID_DIR/gremlin.pid
+fi
+
+if [ -z "$GREMLIN_YAML" ]; then
+  GREMLIN_YAML=$GREMLIN_HOME/conf/gremlin-server.yaml
+fi
+
+if [ ! -r "$GREMLIN_YAML" ]; then
+  # try relative to home
+  GREMLIN_YAML="$GREMLIN_HOME/$GREMLIN_YAML"
+  if [ ! -r "$GREMLIN_YAML" ]; then
+    echo WARNING: $GREMLIN_YAML is unreadable
+  fi
+fi
+
+status() {
+  if [ -r "$PID_FILE" ] ; then
+    PID=$(cat "$PID_FILE")
+    ps -p "$PID" &> /dev/null
+    RUNNING=$?
+    if [ $RUNNING -gt 0 ]; then
+      echo Server not running
+    else
+      echo Server running with PID $(cat "$PID_FILE")
+    fi
+  else
+    echo Server not running or PID file not found.
+  fi
+}
+
+stop() {
+  if [ -r "$PID_FILE" ] ; then
+    PID=$(cat "$PID_FILE")
+    ps -p "$PID" &> /dev/null
+    RUNNING=$?
+    if [ $RUNNING -gt 0 ]; then
+      echo Server not running
+    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
+  else
+    echo Server not running or PID file not found.
+  fi
+  rm -f "$PID_FILE"
+}
+
+start() {
+
+  if [ -r "$PID_FILE" ] ; then
+    PID=$(cat "$PID_FILE")
+    ps -p "$PID" &> /dev/null
+    RUNNING=$?
+    if [ $RUNNING -eq 0 ]; then
+      echo Server already running with PID $(cat "$PID_FILE").
+      exit 1
+    fi
+  fi
+
+  if [ -z "$RUNAS" ]; then
+    JAVA_HOME="$JAVA_HOME" JAVA_OPTIONS="$JAVA_OPTIONS" $GREMLIN_CMD 
"$GREMLIN_YAML" >> "$LOG_FILE" 2>&1 &
+    PID=$!
+    disown $PID
+    echo $PID > "$PID_FILE"
+  else
+    su -c "JAVA_HOME=\"$JAVA_HOME\" JAVA_OPTIONS=\"$JAVA_OPTIONS\" 
$GREMLIN_CMD \"$GREMLIN_YAML\" >> \"$LOG_FILE\" 2>&1 & echo \$! "  "$RUNAS" > 
"$PID_FILE"
+    chown "$RUNAS" "$PID_FILE"
+  fi
+
+}
+
+case "$1" in
+  status)
+    status
+    ;;
+  restart)
+    stop
+    start
+    ;;
+  start)
+    start
+    ;;
+  stop)
+    stop
+    ;;
+  *)
+    echo "Usage: $0 {start|stop|restart|status}"; exit 1;
+    ;;
+esac

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/92fdf91f/gremlin-server/src/main/bin/gremlin-server.service
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/bin/gremlin-server.service 
b/gremlin-server/src/main/bin/gremlin-server.service
new file mode 100644
index 0000000..21037d7
--- /dev/null
+++ b/gremlin-server/src/main/bin/gremlin-server.service
@@ -0,0 +1,18 @@
+
+[Unit]
+Description=Apache Tinkerpop Gremlin server daemon
+Documentation=http://tinkerpop.apache.org/
+After=network.target
+
+[Service]
+WorkingDirectory=/opt/apache-tinkerpop-gremlin-server
+EnvironmentFile=/opt/apache-tinkerpop-gremlin-server/bin/gremlin-server.conf
+ExecStart=/opt/apache-tinkerpop-gremlin-server/bin/gremlin-server.sh
+KillMode=process
+Restart=no
+RestartSec=60s
+User=gremlin
+Group=gremlin
+
+[Install]
+WantedBy=multi-user.target

Reply via email to