[PATCH] (issue1692) Ãberarbeitetes Init script
Wald Commits
scm-commit at wald.intevation.org
Tue Feb 4 11:09:00 CET 2014
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1391508537 -3600
# Node ID 1709c429818afd8d6ba14beb310b60637d91bd43
# Parent f4e32ac4e55c1a51d4b2c210b8ee5a87a12d25bf
(issue1692) Ãberarbeitetes Init script
diff -r f4e32ac4e55c -r 1709c429818a contrib/init.d/README.txt
--- a/contrib/init.d/README.txt Fri Jan 31 19:57:35 2014 +0100
+++ b/contrib/init.d/README.txt Tue Feb 04 11:08:57 2014 +0100
@@ -1,15 +1,19 @@
SLES-Init-Script fuer Dive4Elements River:
Installation als root:
-- Kopieren nach /etc/init.d/d4e-river
+- d4e-river Kopieren nach /etc/init.d/d4e-river
- chmod 755 /etc/init.d/d4e-river
- insserv /etc/init.d/d4e-river
+- d4e-start Kopieren nach /opt/flys/d4e-start
+- chmod 755 /opt/flys/d4e-start
- /etc/init.d/d4e-river start
+
Deinstallation als root:
- /etc/init.d/d4e-river stop
- insserv -r /etc/init.d/d4e-river
- rm /var/log/d4e-river.log /var/run/d4e-river.pid /etc/init.d/d4e-river
+- rm /opt/flys/d4e-start
TODO:
- ggf. logrotate fuer Logdatei /var/log/d4e-river.log konfigurieren
diff -r f4e32ac4e55c -r 1709c429818a contrib/init.d/d4e-river
--- a/contrib/init.d/d4e-river Fri Jan 31 19:57:35 2014 +0100
+++ b/contrib/init.d/d4e-river Tue Feb 04 11:08:57 2014 +0100
@@ -13,52 +13,141 @@
### END INIT INFO
RUNAS=flys
-DIR="/opt/flys/current/server"
+START_SCRIPT="/opt/flys/d4e-start"
+NAME="$(basename $0)"
+SHUTDOWN_WAIT="30"
-CLASSPATH=
-for l in `find "$DIR/bin/lib" -name \*.jar -print`; do
- CLASSPATH=$CLASSPATH:$l
-done
+export FLYSDIR="/opt/flys/current/server"
+unset ISBOOT
+if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
+ NAME="${NAME:3}"
+ ISBOOT="1"
+fi
-LOGFILE=/var/log/d4e-river.log
-PIDFILE=/var/run/d4e-river.pid
-ARGS="-Xmx256m \
+# remove SUSE's rc name
+if [ "${NAME:0:2}" = "rc" ]; then
+ NAME="${NAME:2}"
+fi
+
+
+export LOGFILE=/var/log/d4e-river.log
+export ARGS="-Xmx256m \
-server \
-Djava.awt.headless=true \
-Dflys.datacage.recommendations.development=false \
- -Djava.io.tmpdir=\"$DIR/cache\" \
+ -Djava.io.tmpdir=$FLYSDIR/cache \
+ -Dflys.backend.enablejmx=true \
-Dflys.uesk.keep.artifactsdir=false \
- -Dwsplgen.bin.path=\"$DIR/bin/wsplgen.exe\" \
+ -Dwsplgen.bin.path=$FLYSDIR/bin/wsplgen.exe \
-Dwsplgen.log.output=false \
- -Dartifact.database.dir=\"$DIR/conf\""
-MAINCLASS=org.dive4elements.artifactdatabase.App
+ -Dlog4j.configuration=file://$FLYSDIR/conf/log4j.properties \
+ -Dartifact.database.dir=$FLYSDIR/conf"
+export MAINCLASS=org.dive4elements.artifactdatabase.App
# For SELinux we need to use 'runuser' not 'su'
if [ -x "/sbin/runuser" ]; then
SU="/sbin/runuser"
else
- SU="/bin/su"
+ SU="/bin/su -m"
fi
+# pulled from RHEL4 /etc/rc.d/init.d/functions
+function checkpid() {
+ local i
+ for i in $* ; do
+ if [ -d "/proc/${i}" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+. /etc/rc.status
+rc_reset
+
+function start() {
+ echo -n "Starting D4E-river server... "
+ if [ -f "/var/lock/subsys/${NAME}" ] ; then
+ if [ -f "/var/run/${NAME}.pid" ]; then
+ read kpid < /var/run/${NAME}.pid
+ if checkpid $kpid 2>&1; then
+ echo "$NAME process already running with pid $kpid"
+ rc_failed 0
+ exit
+ else
+ echo "lock file found but no process running for pid $kpid, continuing"
+ rc_failed 7
+ fi
+ fi
+ fi
+
+ export D4E_PID="/var/run/${NAME}.pid"
+ touch $D4E_PID
+ chown $RUNAS $D4E_PID
+ touch $LOGFILE
+ chown $RUNAS $LOGFILE
+
+ for l in `find "$FLYSDIR/bin/lib" -name \*.jar -print`; do
+ CLASSPATH=$CLASSPATH:$l
+ done
+
+ export CLASSPATH
+
+ $SU $RUNAS -c "$START_SCRIPT"
+ #>> $LOGFILE 2>&1
+ RETVAL="$?"
+ if [ "$RETVAL" -eq 0 ]; then
+ rc_failed 0
+ touch /var/lock/subsys/${NAME}
+ else
+ rc_failed 7
+ fi
+ rc_status -v
+}
+
+function stop() {
+ echo -n "Shutting down D4E-River"
+ if [ -f "/var/lock/subsys/${NAME}" ]; then
+ count="0"
+ if [ -f "/var/run/${NAME}.pid" ]; then
+ read kpid < /var/run/${NAME}.pid
+ kill $kpid
+ until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \
+ [ "$count" -gt "$SHUTDOWN_WAIT" ]; do
+ if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
+ echo -n -e "\nwaiting for processes $kpid to exit"
+ fi
+ sleep 1
+ let count="${count}+1"
+ done
+ if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
+ if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
+ echo -n -e "\nkilling processes which didn't stop"
+ echo -n -e "after "
+ echo -n "$SHUTDOWN_WAIT seconds"
+ fi
+ kill -9 $kpid
+ fi
+ rc_failed 0
+ if [ "$count" -gt "0" ]; then
+ echo -n -e "\n"
+ fi
+ fi
+ rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid
+ fi
+ rc_status -v
+}
+
+
+
+
case "$1" in
start)
- echo "Starting D4E-river server..."
- $SU - $RUNAS -c "/usr/bin/java -classpath $CLASSPATH $ARGS $MAINCLASS" &> $LOGFILE &
- PID=$!
- echo $PID > $PIDFILE
+ start
;;
stop)
- echo "Stopping D4E-river server..."
- PID=`cat $PIDFILE`
- STOPRES=0
- while [ $STOPRES -le 0 ]
- do
- kill -15 $PID &> /dev/null
- STOPRES=$?
- sleep 1
- done
- echo "done."
+ stop
;;
restart)
$0 stop && $0 start
diff -r f4e32ac4e55c -r 1709c429818a contrib/init.d/d4e-start
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/init.d/d4e-start Tue Feb 04 11:08:57 2014 +0100
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd $FLYSDIR
+/usr/bin/java -classpath $CLASSPATH $ARGS $MAINCLASS >> $LOGFILE 2>&1&
+echo $! > $D4E_PID
More information about the Dive4elements-commits
mailing list