Skip to content
Snippets Groups Projects
Commit 9efe1b7e authored by brinn's avatar brinn
Browse files

add: write PID file on server startup and remove it on shutdown

add: script status.sh for checking the server status

SVN: 23585
parent fa7546cc
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@ if [ ${JETTY_BIN_DIR#/} == ${JETTY_BIN_DIR} ]; then
JETTY_BIN_DIR="`pwd`/${JETTY_BIN_DIR}"
fi
JETTY_PID_FILE="$JETTY_BIN_DIR/../openbis.pid"
source "$JETTY_BIN_DIR/../etc/jetty.properties"
source "$JETTY_BIN_DIR/../etc/openbis.conf"
cd "$JETTY_BIN_DIR"/..
......@@ -16,4 +18,51 @@ else
JVM="`which java`"
fi
JETTY_LIB_PATH="$JETTY_BIN_DIR"/../webapps/openbis/WEB-INF/jython-lib
\ No newline at end of file
JETTY_LIB_PATH="$JETTY_BIN_DIR"/../webapps/openbis/WEB-INF/jython-lib
awkBin()
{
# We need a awk that accepts variable assignments with '-v'
case `uname -s` in
"SunOS")
echo "nawk"
return
;;
esac
# default
echo "awk"
}
isPIDRunning()
{
if [ "$1" = "" ]; then
return 1
fi
if [ "$1" = "fake" ]; then # for unit tests
return 0
fi
# This will have a return value of 0 on BSDish systems
isBSD="`ps aux > /dev/null 2>&1; echo $?`"
AWK=`awkBin`
if [ "$isBSD" = "0" ]; then
if [ "`ps aux | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then
return 0
else
return 1
fi
else
if [ "`ps -ef | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then
return 0
else
return 1
fi
fi
}
checkNotRoot()
{
if [ $UID -eq 0 ]; then
echo "openBIS Data Store Server cannot run as user 'root'." > /dev/stderr
exit 1
fi
}
#! /bin/bash
# Shutdown script for CISD openBIS Application Server on Unix / Linux systems
# -------------------------------------------------------------------------
source `dirname "$0"`/setup-env
$JVM -DSTOP.PORT=$JETTY_STOP_PORT \
-DSTOP.KEY=$JETTY_STOP_KEY \
$JAVA_OPTS $JAVA_MEM_OPTS \
-jar start.jar --stop
# Delete PID file
test -f "$JETTY_PID_FILE" && rm -f "$JETTY_PID_FILE"
\ No newline at end of file
#! /bin/bash
if [ $UID -eq 0 ]; then
echo "openBIS Application Server cannot run as user 'root'." > /dev/stderr
exit 1
fi
# Startup script for CISD openBIS Application Server on Unix / Linux systems
# -------------------------------------------------------------------------
source `dirname "$0"`/setup-env
checkNotRoot
$JVM -DSTOP.PORT=$JETTY_STOP_PORT \
-DSTOP.KEY=$JETTY_STOP_KEY \
$JAVA_OPTS $JAVA_MEM_OPTS \
-Dpython.path=$JETTY_LIB_PATH \
-jar start.jar etc/jetty.xml lib=webapps/openbis/WEB-INF/lib >> logs/jetty.out 2>&1 &
# Write PID to PID file
echo $! > "$JETTY_PID_FILE"
\ No newline at end of file
#! /bin/bash
# Status script for CISD openBIS Application Server on Unix / Linux systems
# -------------------------------------------------------------------------
source `dirname "$0"`/setup-env
printStatus()
{
if [ "$1" == "-q" ]; then
QUIET=1
fi
if [ -f $PIDFILE ]; then
PID=`cat $JETTY_PID_FILE`
isPIDRunning $PID
if [ $? -eq 0 ]; then
test -z "$QUIET" && echo "openBIS Application Server is running (pid $PID)"
return 0
else
test -z "$QUIET" && echo "openBIS Application is dead (stale pid $PID)"
return 1
fi
else
test -z "$QUIET" && echo "openBIS Application is not running."
return 2
fi
}
printStatus "$1"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment