Forum Linux.général Librairies pour script de démarrage de tomcat avec jsvc

Posté par .
-2
24
fév.
2012

Bonjour,
J'essaye actuellement de configurer un serveur sous CentOS 6 x86_64 et j'ai un soucis avec le script /etc/init.d/tomcat
Je voudrais faire tourner Tomcat 7 en temps que service avec jsvc afin de gérer le plantage de java mais tous les modèles de script que j'ai pu trouver sur internet utilisent /lib/lsb/init-functions mais je ne trouve pas le paquet lsb-base pour CentOS. J'ai bien trouvé un paquet redhat-lsb, mais comme il dépend de l'installation de cups, X-org, mesa et tout un tas d'autres composants graphiques donc ce ne doit pas être ça.

Certains essayent d'utiliser /etc/default/rcS qui n'est pas non plus disponible, mais surtout j'aurais besoin de start-stop-daemon cependant l'installation de dpkg sur CentOS tiens plus du bricolage chancelant qu'autre chose.

Voici le script que j'aimerais pouvoir faire fonctionner :

#!/bin/sh
#
# /etc/init.d/tomcat -- startup script for the Tomcat servlet engine
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Tomcat.
# Description: Start the Tomcat servlet engine.
### END INIT INFO
set -e
VERSION=7
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=tomcat$VERSION
DESC="Tomcat servlet engine"
DAEMON=/usr/bin/jsvc
CATALINA_HOME=/usr/share/$NAME
DEFAULT=/etc/default/$NAME
. /lib/lsb/init-functions
. /etc/default/rcS
# The following variables can be overwritten in $DEFAULT
# Run Tomcat as this user ID
TOMCAT_USER=tomcat
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 /usr/lib/jvm/java-1.6.0 /usr/lib/jvm/java-1.6.0-openjdk.x86_64 /usr/lib/jre-1.6.0-openjdk.x86_64 /usr/lib/jre-1.5.0 /usr/lib/j2sdk1.4-sun /usr/lib/j2sdk1.4-blackdown /usr/lib/j2se/1.4 /usr/lib/j2sdk1.4-ibm /usr/lib/j2sdk1.3-sun /usr/lib/j2sdk1.3-blackdown /usr/lib/jvm/java-gcj /usr/lib/kaffe"
# Look for the right JVM to use
for jdir in $JDK_DIRS; do
 if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
 JAVA_HOME_TMP="$jdir"
 # checks for a real JDK like environment, needed to check if 
 # really the java-gcj-compat-dev package is installed
 if [ -r "$jdir/bin/jdb" ]; then
 JAVA_HOME="$JAVA_HOME_TMP"
 fi
 fi
done
export $JAVA_HOME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/usr/share/$NAME
# Use the Java security manager? (yes/no)
TOMCAT_SECURITY=no
# Timeout in seconds for the shutdown of all webapps
TOMCAT_SHUTDOWN=30
# End of variables that can be overwritten in $DEFAULT
# overwrite settings from default file
if [ -f "$DEFAULT" ]; then
 . "$DEFAULT"
fi
test -f $DAEMON || exit 0
[ -z "$TOMCAT_USER" ] && TOMCAT_USER=tomcat7
# Check if we use gij
gij=no
"$JAVA_HOME/bin/java" -version 2>&1 | grep -q "^gij (GNU libgcj)" && gij=yes
# gij doesn't support a security manager yet (see bug #399595)
if [ "$gij" = "yes" ]; then
 echo -e "The java-gcj-compat-dev environment currently doesn't\nsupport a security manager. See README.Debian." | logger -p daemon.warning -t $NAME
fi
# Set java.awt.headless=true if JAVA_OPTS is not set so the
# Xalan XSL transformer can work without X11 display on JDK 1.4+
# It also looks like the default heap size of 64M is not enough for most cases
# se the maximum heap size is set to 128M
if [ -z "$JAVA_OPTS" ]; then
 JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
fi
JAVA_OPTS="$JAVA_OPTS -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -Dcatalina.base=$CATALINA_BASE -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_BASE/temp"
JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx512m -Dfile.encoding=UTF8 -Duser.timezone=GMT -Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config"
# Set the JSP compiler if set in the tomcat7.default file
if [ -n "$JSP_COMPILER" ]; then
 JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=$JSP_COMPILER"
fi
if [ "$TOMCAT5_SECURITY" = "yes" ]; then
 JAVA_OPTS="$JAVA_OPTS -Djava.security.manager -Djava.security.policy=$CATALINA_BASE/conf/catalina.policy"
fi
# juli LogManager disabled if running under gij (see bug #395167)
if [ "$gij" != "yes" ]; then
 JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
fi
# Define other required variables
CATALINA_PID="/var/run/$NAME.pid"
BOOTSTRAP_CLASS=org.apache.catalina.startup.Bootstrap
JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"
# Look for Java Secure Sockets Extension (JSSE) JARs
if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then
 JSSE_HOME="${JAVA_HOME}/jre/"
fi
export JSSE_HOME
case "1ドル" in
 start)
 if [ -z "$JAVA_HOME" ]; then
 log_failure_msg "no JDK found - please set JAVA_HOME"
 exit 1
 fi
 if [ ! -d "$CATALINA_BASE/conf" ]; then
 log_failure_msg "invalid CATALINA_BASE specified"
 exit 1
 fi
 log_daemon_msg "Starting $DESC" "$NAME"
 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \
 --user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
 >/dev/null; then
 # Create catalina.policy (for the security manager)
 rm -f "$CATALINA_BASE/conf/catalina.policy"
 umask 022
 echo "// AUTO-GENERATED FILE -- DO NOT EDIT!" \
 > "$CATALINA_BASE/conf/catalina.policy"
 echo "// Edit the files in /etc/$NAME/policy.d/ instead" \
 >> "$CATALINA_BASE/conf/catalina.policy"
 echo "" >> "$CATALINA_BASE/conf/catalina.policy"
 cat /etc/$NAME/policy.d/*.policy \
 >> "$CATALINA_BASE/conf/catalina.policy"
 # Clean up and set permissions on required files
 find "$CATALINA_BASE"/temp/ -mindepth 1 -exec rm -f {} +
 chown --dereference "$TOMCAT_USER" "$CATALINA_BASE/conf" \
 "$CATALINA_BASE/conf/tomcat-users.xml" \
 "$CATALINA_BASE/logs" "$CATALINA_BASE/temp" \
 "$CATALINA_BASE/webapps" "$CATALINA_BASE/work" \
 || true
 $DAEMON -user "$TOMCAT_USER" -cp "$JSVC_CLASSPATH" \
 -outfile SYSLOG -errfile SYSLOG \
 -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"
 #ajout de cela car bug https://bugs.launchpad.net/ubuntu/+source/tomcat5.5/+bug/97096
 tail /var/log/$NAME/catalina.out > /dev/null &
 else
 log_progress_msg "(already running)"
 fi
 log_end_msg 0
 ;;
 stop)
 log_daemon_msg "Stopping $DESC" "$NAME"
 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \
 --user "$TOMCAT_USER" --startas "$JAVA_HOME/bin/java" \
 >/dev/null; then
 log_progress_msg "(not running)"
 else
 $DAEMON -cp "$JSVC_CLASSPATH" -pidfile "$CATALINA_PID" \
 -stop "$BOOTSTRAP_CLASS"
 fi
 log_end_msg 0
 ;;
 status)
 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \
 --user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
 >/dev/null; then
 if [ -f "$CATALINA_PID" ]; then
 log_success_msg "$DESC is not running, but pid file exists."
 else
 log_success_msg "$DESC is not running."
 fi
 else
 log_success_msg "$DESC is running with pid `cat $CATALINA_PID`"
 fi
 ;;
 restart|force-reload)
 if start-stop-daemon --test --stop --pidfile "$CATALINA_PID" \
 --user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
 >/dev/null; then
 0ドル stop
 sleep 1
 fi
 0ドル start
 ;;
 try-restart)
 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \
 --user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
 >/dev/null; then
 0ドル start
 fi
 ;;
 *)
 log_success_msg "Usage: 0ドル {start|stop|restart|try-restart|force-reload|status}"
 exit 1
 ;;
esac
exit 0

  • # faire simple

    Posté par . Évalué à 2.

    installer tomcat avec le gestionnaire de paquet de ta distrib (centOS)

    ca va surement te faire un script de demarrage du service.

    ensuite plus qu'a l'adapter pour faire ce que tu veux en t'inspirant de ce que fait Debian

    vu que le script que tu nous a donné est pour debian

    Written by Miquel van Smoorenburg miquels@cistron.nl.
    Modified for Debian GNU/Linux by Ian Murdock imurdock@gnu.ai.mit.edu.
    Modified for Tomcat by Stefan Gybas sgybas@debian.org.

    • [^] # Re: faire simple

      Posté par . Évalué à 0.

      Pour avoir Tomcat 7 sur CentOS 6 il m'a fallut l'installer à partir du repo JPackage.
      À l'installation avec Yum aucun script n'a été généré. De toute façon le script par défaut utilise startup.sh et non jsvc.
      Comment pourrais-je adapter ce script pour utiliser jsvc ? (Sur un serveur web en production mieux vaut gérer les plantages potentiels de java)

      • [^] # Re: faire simple

        Posté par . Évalué à 3.

        je ne sais pas ce qu'est JSVC ni ce que tu en attends, mais d'apres le script que tu cites, JSVC c'est juste des options à passer dans le classpath du lancement ou de l'arret

        il est definit ici :

        DAEMON=/usr/bin/jsvc
        CATALINA_HOME=/usr/share/$NAME
        JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"

        puis utiliser au demarrage ici :

        $DAEMON -user "$TOMCAT_USER" -cp "$JSVC_CLASSPATH" \
        -outfile SYSLOG -errfile SYSLOG \
        -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"

        et pour l'arret là :

        $DAEMON -cp "$JSVC_CLASSPATH" -pidfile "$CATALINA_PID" \
        -stop "$BOOTSTRAP_CLASS"

        start-stop-daemon n'est là que pour tester s'il peut lancer ou pas le daemon,
        tu dois pouvoir t'en passer ou utiliser le system redhat/centOS

        • [^] # Re: faire simple

          Posté par . Évalué à 0.

          Regarde cette ligne :

          DAEMON=/usr/bin/jsvc
          
          

          jsvc fait partie de Apache Commons Daemon
          Il permet de faire fonctionner un programme java utilisant son API (dans ce cas Tomcat) en tant que démon.
          Avec le lancement classique un crash de java signifie que Tomcat est down, mais avec jsvc il récupère le crash et reste up. Ce qui est préférable sur un serveur web en production.

  • # Script qui s'arrête

    Posté par . Évalué à 0.

    J'essaye d'adapter le script pour ne pas utiliser start-stop-daemon, mais il s'arrête quelque part dans ce bloc sans me dire ni où ni pourquoi :

    ISSTOPPED="0"
    if [ -f "${CATALINA_PID}" ]; then
     read kpid < $CATALINA_PID
     if checkpid $kpid 2>&1; then
     ISSTOPPED="-1"
     fi
    else
     pid="$(pgrep -u ${TOMCAT_USER} java)"
     if [ -n "$pid" ]; then
     ISSTOPPED="-1"
     else
     rm -f $CATALINA_PID
     fi
    fi
    
    
    • [^] # Re: Script qui s'arrête

      Posté par . Évalué à 3.

      debug... à defaut d'option debug, met des echos avant/apres chaque action
      tu verras vite où il s'arrete

      • [^] # Re: Script qui s'arrête

        Posté par . Évalué à 0.

        En fait, mon problème vient de cette ligne-là :

        pid=$(pgrep -u ${TOMCAT_USER} jsvc)
        
        

        Lorsque pgrep renvoie un pid, tout se passe correctement, mais si tomcat n'est pas démarré et que pgrep ne renvoie rien, l'exécution du script ne va pas plus loin que cette ligne.

        • [^] # Re: Script qui s'arrête

          Posté par . Évalué à 1.

          faut tester differement.

          perso j'aurais ecris (meme si ce n'est peut-etre pas dans les regles de l'art :

          pid=pgrep -u $TOMCAT_USER jsvc

          • [^] # Re: Script qui s'arrête

            Posté par . Évalué à 1.

            J'ai essayé toutes les formes possibles déjà et le résultat est le même.

            Le simple fait d'avoir une commande pgrep avec résultat vide arrête le script. J'ai fait deux tests en mettant une commande pgrep sans résultat puis une commande avec résultat au début de mon script.

            Premier test :

            echo 'begin test'
            pgrep test
            echo 'end test'
            
            

            Résultat :

            begin test
            
            

            Second Test :

            echo 'begin test'
            pgrep tty
            echo 'end test'
            
            

            Résultat :

            begin test
            1510
            1512
            1513
            1515
            1517
            1519
            1521
            end test
            Starting Tomcat servlet engine tomcat7
            (already running)
            
            
            • [^] # Re: Script qui s'arrête

              Posté par . Évalué à 2. Dernière modification le 26 février 2012 à 15:56.

              tu dois avoir un probleme dans ton linux,
              car sur le mien (en testant sur apache2 avec le user = www-data) ca marche
              il va bien jusqu'a la fin

              j'utilise le shell bash, et je n'est fait que copier/coller ton code

              # pour tester
              CATALINA_PID=/tmp/catalina
              TOMCAT_USER=www-data
              # le script avec des echos pour voir jusqu'ou il va
              ISSTOPPED="0"
              if [ -f "${CATALINA_PID}" ]; then
              echo lecture du pid
               read kpid < $CATALINA_PID
               echo le pid est : $kpid
               if checkpid $kpid 2>&1; then
              ISSTOPPED="-1"
               fi
              else
              pid="$(pgrep -u ${TOMCAT_USER} apache2)"
               echo le pid est $pid
               if [ -n "$pid" ]; then
              ISSTOPPED="-1"
               else
              rm -f $CATALINA_PID
               fi
              fi
              echo etat: $ISSTOPPED
              echo FIN
              
              

              me renvoie bien

              ./test.sh
              le pid est 10900 10902 10905 10907 11108 11954 12392 12694 12864 14501 15451
              etat: -1
              FIN

              donc il va bien au bout du deroulement.

              par contre il considere que $pid est vide, alors qu'il contient bien des valeurs.
              c'est donc ton test sur $pid qui n'est pas bon

              • [^] # Re: Script qui s'arrête

                Posté par . Évalué à 0.

                Non, c'était bien pgrep qui posait problème, et je viens de trouver la raison. Il y avait cette ligne au début du script :

                set -e
                
                

                Je ne sais pas trop à quoi elle servait mais le fait de la commenter fait que pgrep ne plante plus le script.

  • # Et Voilà !

    Posté par . Évalué à 1.

    Je crois être arrivé à un résultat fonctionnel :

    #!/bin/sh
    #
    # /etc/init.d/tomcat -- startup script for the Tomcat servlet engine
    #
    . /etc/init.d/functions
    VERSION=7
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    NAME=tomcat$VERSION
    DESC="Tomcat servlet engine"
    DAEMON=/usr/bin/jsvc
    CATALINA_HOME=/usr/share/$NAME
    DEFAULT=/etc/default/$NAME
    # Run Tomcat as this user ID
    TOMCAT_USER=tomcat
    # The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
    # defined in $DEFAULT)
    JDK_DIRS="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 /usr/lib/jvm/java-1.6.0 /usr/lib/jvm/java-1.6.0-openjdk.x86_64 /usr/lib/jre-1.6.0-openjdk.x86_64 /usr/lib/jre-1.5.0 /usr/lib/j2sdk1.4-sun /usr/lib/j2sdk1.4-blackdown /usr/lib/j2se/1.4 /usr/lib/j2sdk1.4-ibm /usr/lib/j2sdk1.3-sun /usr/lib/j2sdk1.3-blackdown /usr/lib/jvm/java-gcj /usr/lib/kaffe"
    # Look for the right JVM to use
    for jdir in $JDK_DIRS; do
     if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
     JAVA_HOME_TMP="$jdir"
     # checks for a real JDK like environment, needed to check if 
     # really the java-gcj-compat-dev package is installed
     if [ -r "$jdir/bin/jdb" ]; then
     JAVA_HOME="$JAVA_HOME_TMP"
     fi
     fi
    done
    export JAVA_HOME
    # Directory for per-instance configuration files and webapps
    CATALINA_BASE=/usr/share/$NAME
    # Use the Java security manager? (yes/no)
    TOMCAT_SECURITY=no
    # Timeout in seconds for the shutdown of all webapps
    TOMCAT_SHUTDOWN=30
    # End of variables that can be overwritten in $DEFAULT
    # overwrite settings from default file
    if [ -f "$DEFAULT" ]; then
     . "$DEFAULT"
    fi
    test -f $DAEMON || exit 0
    [ -z "$TOMCAT_USER" ] && TOMCAT_USER=tomcat7
    # Check if we use gij
    gij=no
    "$JAVA_HOME/bin/java" -version 2>&1 | grep -q "^gij (GNU libgcj)" && gij=yes
    # gij doesn't support a security manager yet (see bug #399595)
    if [ "$gij" = "yes" ]; then
     echo -e "The java-gcj-compat-dev environment currently doesn't\nsupport a security manager. See README.Debian." | logger -p daemon.warning -t $NAME
    fi
    # Set java.awt.headless=true if JAVA_OPTS is not set so the
    # Xalan XSL transformer can work without X11 display on JDK 1.4+
    # It also looks like the default heap size of 64M is not enough for most cases
    # se the maximum heap size is set to 128M
    if [ -z "$JAVA_OPTS" ]; then
     JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
    fi
    JAVA_OPTS="$JAVA_OPTS -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -Dcatalina.base=$CATALINA_BASE -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_BASE/temp"
    JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx512m -Dfile.encoding=UTF8 -Duser.timezone=GMT -Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config"
    # Set the JSP compiler if set in the tomcat7.default file
    if [ -n "$JSP_COMPILER" ]; then
     JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=$JSP_COMPILER"
    fi
    if [ "$TOMCAT_SECURITY" = "yes" ]; then
     JAVA_OPTS="$JAVA_OPTS -Djava.security.manager -Djava.security.policy=$CATALINA_BASE/conf/catalina.policy"
    fi
    # juli LogManager disabled if running under gij (see bug #395167)
    if [ "$gij" != "yes" ]; then
     JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
    fi
    # Define other required variables
    CATALINA_PID="/var/run/$NAME.pid"
    BOOTSTRAP_CLASS=org.apache.catalina.startup.Bootstrap
    JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/tomcat-juli.jar"
    export CATALINA_PID
    # Look for Java Secure Sockets Extension (JSSE) JARs
    if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then
     JSSE_HOME="${JAVA_HOME}/jre/"
    fi
    export JSSE_HOME
    start() {
     if [ -z "$JAVA_HOME" ]; then
     echo "no JDK found - please set JAVA_HOME"
     exit 1
     fi
     if [ ! -d "$CATALINA_BASE/conf" ]; then
     echo "invalid CATALINA_BASE specified"
     exit 1
     fi
     echo "Starting $DESC" "$NAME"
     ISSTARTED=-1
     if [ -f "${CATALINA_PID}" ]; then
     read kpid < $CATALINA_PID
     if checkpid $kpid 2>&1; then
     ISSTARTED=0
     else
     rm -f $CATALINA_PID
     fi
     else
     pid=$(pgrep -u ${TOMCAT_USER} jsvc)
     if [ -n "$pid" ]; then
     ISSTARTED=0
     fi
     fi
     if [ $ISSTARTED -ne 0 ]; then
     # Create catalina.policy (for the security manager)
     rm -f "$CATALINA_BASE/conf/catalina.policy"
     umask 022
     echo "// AUTO-GENERATED FILE -- DO NOT EDIT!" \
     > "$CATALINA_BASE/conf/catalina.policy"
     echo "// Edit the files in /etc/$NAME/policy.d/ instead" \
     >> "$CATALINA_BASE/conf/catalina.policy"
     echo "" >> "$CATALINA_BASE/conf/catalina.policy"
     policies=$(ls $CATALINA_BASE/conf/policy.d/*.policy 2> /dev/null | wc -l)
     if [ "$policies" != "0" ]; then
     cat $CATALINA_BASE/conf/policy.d/*.policy \
     >> "$CATALINA_BASE/conf/catalina.policy"
     fi
     # Clean up and set permissions on required files
     find "$CATALINA_BASE"/temp/ -mindepth 1 -exec rm -f {} +
     chown --dereference "$TOMCAT_USER" "$CATALINA_BASE/conf" \
     "$CATALINA_BASE/conf/tomcat-users.xml" \
     "$CATALINA_BASE/logs" "$CATALINA_BASE/temp" \
     "$CATALINA_BASE/webapps" "$CATALINA_BASE/work" \
     || true
     $DAEMON -user "$TOMCAT_USER" -cp "$JSVC_CLASSPATH" \
     -outfile SYSLOG -errfile SYSLOG \
     -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"
     else
     echo "(already running)"
     fi
    }
    stop() {
     echo "Stopping $DESC" "$NAME"
     ISSTARTED=-1
     if [ -f "${CATALINA_PID}" ]; then
     read kpid < $CATALINA_PID
     if checkpid $kpid 2>&1; then
     ISSTARTED=0
     fi
     else
     pid=$(pgrep -u ${TOMCAT_USER} jsvc)
     if [ -n "$pid" ]; then
     ISSTARTED=0
     fi
     fi
     if [ $ISSTARTED -eq 0 ]; then
     $DAEMON -cp "$JSVC_CLASSPATH" -pidfile "$CATALINA_PID" \
     -stop "$BOOTSTRAP_CLASS"
     else
     echo "(not running)"
     fi
    }
    restart() {
     # Restart
     stop
     echo "Sleeping for 2 seconds."
     sleep 2
     start
    }
    status() {
     RETVAL="1"
     if [ -f "${CATALINA_PID}" ]; then
     read kpid < $CATALINA_PID
     if checkpid $kpid 2>&1; then
     echo "0ドル is already running (${kpid})"
     RETVAL="0"
     else
     echo "lock file found but no process running for pid $kpid"
     fi
     else
     pid=$(pgrep -u ${TOMCAT_USER} jsvc)
     if [ -n "$pid" ]; then
     echo "0ドル running (${pid}) but no PID file exists"
     RETVAL="0"
     else
     echo "0ドル is stopped"
     fi
     fi
     return $RETVAL
    }
    case "1ドル" in
     start)
     start
     ;;
     stop)
     stop
     ;;
     restart)
     restart
     ;;
     status)
     status
     ;;
     *)
     echo $"Usage: tomcat {start|stop|restart|status}"
     exit 1
    esac
    exit 0
    
    

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.