YaCy Startup init script für CentOS Fedora und RedHat

Hier finden YaCy User Hilfe wenn was nicht funktioniert oder anders funktioniert als man dachte. Bei offensichtlichen Fehlern diese bitte gleich in die Bugs (http://bugs.yacy.net) eintragen.
Forumsregeln
In diesem Forum geht es um Benutzungsprobleme und Anfragen für Hilfe. Wird dabei ein Bug identifiziert, wird der thread zur Bearbeitung in die Bug-Sektion verschoben. Wer hier also einen Thread eingestellt hat und ihn vermisst, wird ihn sicherlich in der Bug-Sektion wiederfinden.

YaCy Startup init script für CentOS Fedora und RedHat

Beitragvon jottschi » Mi Jul 01, 2009 12:47 pm

Hallo hier ein init Script für RH und CentOS -Gewöhnte. In der Suche habe ich nichts gefunden..
Aber Florian Richter hat eins für openSuSE gebaut, ich habe es für CentOS umgebaut..
Code: Alles auswählen
#!/bin/bash
#
# init script for YaCy
#
# Provided by Matthias Kempka, 26.12.2004
# Updated by Florian Richter, 17.7.2008
# http://www.yacy-websuche.de/wiki/index.php/De:OBSInstall
#
# Updated for plain yacy install from yacy provided tar.gz file
# by Ralph Gottschalkson 01. July 2009
# Tested under CentOS 4 any RH-Flavour should work

# chkconfig:   - 20 80
# description: Distributed web search engine
### BEGIN INIT INFO
# Provides:          yacy
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     3 5
# Default-Stop:
# Short-Description: Distributed web search engine
# Description:       yacy is a distributed search engine
#                    config-file is /etc/yacy/yacy.conf
### END INIT INFO

NAME="yacy"
DESC="YaCy P2P Web Search"
# EDIT THIS
YACY_HOME="/WHERE/IS/yacy"
DATA_HOME="/WHERE/IS/yacy"
PID_FILE="/var/run/yacy.pid"
USER=MYYACIUSER
#USER=yaci


# Set this to the maximum number of seconds the script should try to shutdown
# yacy. You might want to increase this on slower peers or for bigger
# databases.
SHUTDOWN_TIMEOUT=50

# Default niceness if not set in config file
NICE_VAL=0

JAVA_ARGS="-server -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+UseAdaptiveSizePolicy"
#check if system supports large memory pages and enable it if possible
HUGEPAGESTOTAL="$(cat /proc/meminfo | grep HugePages_Total | sed s/[^0-9]//g)"
if [ -n "$HUGEPAGESTOTAL" ] && [ $HUGEPAGESTOTAL -ne 0 ]
then
  JAVA_ARGS="$JAVA_ARGS -XX:+UseLargePages"
fi

# Source function library.
. /etc/rc.d/init.d/functions

[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
if [ "$(id -u)" != "0" ] ; then
        echo "please run this script as root!"
        exit 4
fi

JAVA=$(which java 2> /dev/null)
if [ ! -x "$JAVA" ]; then
        echo "The 'java' command is not executable."
        echo "Either you have not installed java or it is not in your PATH"
        if [ $1 == "stop" -a $2 == "--force" ]; then exit 0; else exit 1; fi
fi

cd $YACY_HOME

JAVA_ARGS="$JAVA_ARGS -Djava.awt.headless=true"
#get javastart args
if [ -f DATA/SETTINGS/yacy.conf ]
then
        # startup memory
        for i in Xmx Xms; do
                j=$(grep javastart_$i DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//');
                if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi;
        done

        # Priority
        j=$(grep javastart_priority DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//');

        if [ ! -z "$j" ];then
                if [ -n $j ]; then NICE_VAL=$j; fi;
        fi

else
        JAVA_ARGS="-Xmx120m -Xms120m $JAVA_ARGS"
fi


# generating the proper classpath
CLASSPATH=""
for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
for N in libx/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
CLASSPATH="classes:.:htroot:$CLASSPATH"

if [ -f $PID_FILE ]; then
        pid=$(cat "$PID_FILE")
        pidno=$( ps ax | grep "$pid" | awk '{ print $1 }' | grep "$pid" )
fi

RETVAL=0
case "$1" in
  start)
        if [ -n "$pidno" ]; then
                echo "already running"
                exit 0
        fi

        echo -n "Starting $DESC: "
        ARGS="$JAVA_ARGS -classpath $CLASSPATH yacy"

        cmdline="$JAVA $ARGS"
        nice -$NICE_VAL sudo -u yacy $cmdline &>/dev/null &
        echo $! >$PID_FILE
        sleep 1
        ps ax|grep "^ *$(cat $PID_FILE)" > /dev/null
        if [ "$?" == "0" ]; then

                echo
                RETVAL=0
        else

                echo
                RETVAL=1
        fi
        ;;

  stop)
        if [ -n "$pidno" ]; then

                echo -n "Stopping $DESC: "
                cd $YACY_HOME
                cmdline="$JAVA $JAVA_ARGS -cp $CLASSPATH yacy -shutdown"
                sudo -u yacy $cmdline &>/dev/null &
                shutdown_pid=$!

                timeout=$SHUTDOWN_TIMEOUT
                while [ -n "$pidno" ]; do
                        let timeout=$timeout-1
                        if [ $timeout -eq 0 ]; then
                                kill -9 $pid &>/dev/null
                                # dont forget to kill shutdown process if necessary
                                shutdown_pid=$( ps ax | grep $shutdown_pid | awk '{ print $1 }
' | grep $shutdown_pid )
                                if [ -n "$shutdown_pid" ] ; then
                                        kill -9 $shutdown_pid
                                fi
                                break
                        fi
                        echo -n  "."
                        sleep 1
                        pidno=$( ps ax | grep $pid | awk '{ print $1 }' | grep $pid )
                done
                rm $PID_FILE
                cd - >/dev/null

                echo
                exit 0
        fi
        echo "not running."
        ;;

  restart)
        $0 stop
        sleep 1
        $0 start
        ;;
  reload)
        $0 restart
        ;;
  status)
        # needed by Fedora
        if [ -n "$pidno" ]; then
                echo "is running."
                exit 0
        else
                if [ -f $PID_FILE ]; then
                        echo "is dead, but pid file exists."
                        exit 1
                else
                        echo "is not running."
                        exit 3
                fi
        fi
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac

exit $RETVAL

jottschi
 
Beiträge: 3
Registriert: Mi Jul 01, 2009 11:06 am

Zurück zu Fragen und Antworten

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste