From 9641e978a6a4bafb5974fa8414248ea4e31ce1e4 Mon Sep 17 00:00:00 2001 From: Ezequiel Bergamaschi Date: Mon, 26 May 2014 00:19:10 -0300 Subject: [PATCH] adding wisemapping service script --- distribution/package-bin.sh | 1 + distribution/service/wisemapping | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 distribution/service/wisemapping diff --git a/distribution/package-bin.sh b/distribution/package-bin.sh index 97f4e87a..cae1ff18 100755 --- a/distribution/package-bin.sh +++ b/distribution/package-bin.sh @@ -53,6 +53,7 @@ cp $BASE_DIR/wisemapping.xml $JETTY_DIR/contexts/ # Distribute scripts cp -r $BASE_DIR/../config/ $TARGET_DIR/wisemapping-$WISE_VERSION/config cp ./start.sh ${JETTY_DIR}/ +cp -r $BASE_DIR/service $TARGET_DIR/wisemapping-$WISE_VERSION/service # Store version echo $1 > $WISE_WEBAPP_DIR/version diff --git a/distribution/service/wisemapping b/distribution/service/wisemapping new file mode 100755 index 00000000..95b1e466 --- /dev/null +++ b/distribution/service/wisemapping @@ -0,0 +1,72 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: wisemapping +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: wisemapping +# Description: www.wisemapping.com +### END INIT INFO + +set -e +set -u + +#environmental variables +JAVA_HOME="/usr/lib/jvm/java7" +JDK_HOME=$JAVA_HOME +export PATH=$JAVA_HOME/bin:$PATH +WISE_HOME="/opt/wisemapping" +PID_FILE="$WISE_HOME/.pid" +SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) + +preInitChecks() { + MYSQL_STATUS=`pgrep mysql` + if [ -z $MYSQL_STATUS ]; then + service mysql start >/dev/null 2>&1 + fi +} + +wiseStatus() { + echo `pgrep -f "$WISE_HOME/start.jar"` +} + +case "${1:-''}" in + 'start') + #preInitChecks + cd $WISE_HOME + echo "Starting Wisemapping..." + java -Xmx256m -Dorg.apache.jasper.compiler.disablejsr199=true -jar $WISE_HOME/start.jar > $WISE_HOME/logs/start.log 2>&1 & + PID=$! + cd - >/dev/null 2>&1 + echo "proccess id: $PID" + echo "$PID" > $PID_FILE + ;; + 'stop') + if [ ! -f $PID_FILE ]; then + PID=$(wiseStatus) + else + PID=`cat $PID_FILE` + rm $PID_FILE >/dev/null 2>&1 + fi + kill $PID + echo "Wisemapping stopped" + ;; + 'restart') + set +e; $SELF stop; set -e + $SELF start + ;; + 'status') + STATUS=$(wiseStatus) + if [ -n "$STATUS" ]; then + echo "Wisemapping server is running, pid: $STATUS" + else + echo "Wisemapping is stopped" + fi + ;; + + *) + echo "Usage: $SELF start|stop|restart|status" + exit 1 + ;; +esac