Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Feb 2006 22:33:10 +0100
From:      Niek Dekker <niekdekker@gmail.com>
To:        freebsd-java@freebsd.org
Subject:   tomcat55 startup script error?
Message-ID:  <e02150200602151333u5a1bb96aq@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I installed the new tomcat55 port on feb. 12. on 6.0-RELEASE
JDK is 1.5.0 native.

When I run the tomcat55.sh stop script, it says:

# /usr/local/etc/rc.d/tomcat55.sh stop
tomcat55 not running? (check /var/run/tomcat55.pid).
#

But the pid file is just there.

I would like to know what's wrong in the script. Here it is:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
#!/bin/sh
#
# $FreeBSD: ports/www/tomcat55/files/tomcat55.sh.in,v 1.3 2006/02/08
13:35:17 lawrance Exp $
#

# PROVIDE: tomcat55
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: FreeBSD shutdown

#
# Configuration settings for tomcat55 in /etc/rc.conf:
#
# tomcat55_enable (bool):
#   Set to "NO" by default.
#   Set it to "YES" to enable tomcat55
#
# tomcat55_flags (str):
#   Set to "" by default.
#   Extra flags passed to start command
#
# tomcat55_catalina_home (str)
#   Set to "/usr/local/tomcat5.5" by default.
#   Set the CATALINA_HOME variable for the Tomcat process
#
# tomcat55_catalina_base (str)
#   Set to "/usr/local/tomcat5.5" by default.
#   Set the CATALINA_BASE variable for the Tomcat process
#
# tomcat55_catalina_tmpdir (str)
#   Set to "/usr/local/tomcat5.5/temp" by default.
#   Set the CATALINA_TMPDIR variable for the Tomcat process
#
# tomcat55_stdout_log (str)
#   Set to "/var/log/tomcat/stdout.log" by default.
#   Set the location for the Tomcat process log (standard output)
#
# tomcat55_stderr_log (str)
#   Set to "/var/log/tomcat/stderr.log" by default.
#   Set the location for the Tomcat process log (error output)
#
# tomcat55_stop_timeout (num)
#   Set to "10" by default.
#   Sets the timeout in seconds to allow tomcat to shutdown.
#   After the timeout has elapsed, tomcat will be killed.
#
# tomcat55_java_home (str):
# tomcat55_java_vendor (str):
# tomcat55_java_version (str):
# tomcat55_java_os (str):
#   Specify the requirements of the Java VM to use. See javavm(1).
#
# tomcat55_classpath (str):
#   Set to "" by default.
#   Addtional classes to add to the CLASSPATH
#
# tomcat55_java_opts (str):
#   Set to "" by default.
#   Java VM args to use.
#

tomcat55_enable=3D"${tomcat55_enable:-"NO"}"
tomcat55_java_version=3D"${tomcat55_java_version:-"1.4+"}"
tomcat55_user=3D"${tomcat55_user:-"root"}"
tomcat55_catalina_home=3D"${tomcat55_catalina_home:-"/usr/local/tomcat5.5"}=
"
tomcat55_catalina_base=3D"${tomcat55_catalina_base:-"/usr/local/tomcat5.5"}=
"
tomcat55_catalina_tmpdir=3D"${tomcat55_catalina_tmpdir:-"/usr/local/tomcat5=
.5/temp"}"
tomcat55_stdout_log=3D"${tomcat55_stdout_log:-"/var/log/tomcat/stdout.log"}=
"
tomcat55_stderr_log=3D"${tomcat55_stderr_log:-"/var/log/tomcat/stderr.log"}=
"
tomcat55_stop_timeout=3D"${tomcat55_stop_timeout:-"10"}"

. /etc/rc.subr

name=3D"tomcat55"
rcvar=3D`set_rcvar`
pidfile=3D"/var/run/tomcat55.pid"

load_rc_config "${name}"

if [ -n "${tomcat55_java_home}" ] ; then
    export JAVA_HOME=3D"${tomcat55_java_home}"
fi

if [ -n "${tomcat55_java_version}" ] ; then
    export JAVA_VERSION=3D"${tomcat55_java_version}"
fi

if [ -n "${tomcat55_java_vendor}" ] ; then
    export JAVA_VENDOR=3D"${tomcat55_java_vendor}"
fi

if [ -n "${tomcat55_java_os}" ] ; then
    export JAVA_OS=3D"${tomcat55_java_os}"
fi

export JAVA_HOME=3D"/usr/local/jdk1.5.0"
export JAVA_VERSION=3D"1.5"
export JAVA_VENDOR=3D"SUN"
export JAVA_OS=3D"FreeBSD"

java_command=3D"/usr/local/bin/java \
    ${tomcat55_java_opts} \
    -Djava.endorsed.dirs=3D$JAVA_ENDORSED_DIRS \
    -classpath
/usr/local/tomcat5.5/bin/bootstrap.jar:/usr/local/tomcat5.5/bin/commons-
logging-api.jar:${tomcat55_classpath} \
    -Dcatalina.base=3D${tomcat55_catalina_base} \
    -Dcatalina.home=3D${tomcat55_catalina_home} \
    -Djava.io.tmpdir=3D${tomcat55_catalina_tmpdir} \
    org.apache.catalina.startup.Bootstrap"

log_args=3D">> ${tomcat55_stdout_log} \
    2>> ${tomcat55_stderr_log} "

# Subvert the check_pid_file procname check.
if [ -f $pidfile ]; then
  read rc_pid junk < $pidfile
  if [ ! -z "$rc_pid" ]; then
    procname=3D`ps -o comm=3D $rc_pid`
  fi
fi

required_files=3D"${tomcat55_catalina_home}/conf/server.xml"

command=3D"/usr/sbin/daemon"
flags=3D"-p ${pidfile} ${java_command} start ${tomcat55_flags} ${log_args}"

start_precmd=3Dpid_touch
stop_cmd=3D"tomcat55_stop"

pid_touch ()
{
    touch $pidfile
    chown $tomcat55_user $pidfile
}

tomcat55_stop() {
    rc_pid=3D$(check_pidfile $pidfile $procname)

    if [ -z "$rc_pid" ]; then
        [ -n "$rc_fast" ] && return 0
        if [ -n "$pidfile" ]; then
            echo "${name} not running? (check $pidfile)."
        else
            echo "${name} not running?"
        fi
        return 1
    fi

    echo "Stopping ${name}."
    ${java_command} stop
    tomcat_wait_max_for_pid ${tomcat55_stop_timeout} ${rc_pid}
    kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
    echo -n > ${pidfile}
}

tomcat_wait_max_for_pid() {
    _timeout=3D$1
    shift
    _pid=3D$1
    _prefix=3D
    while [ $_timeout -gt 0 ] ; do
        echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
        _prefix=3D", "
        sleep 2
        kill -0 $_pid 2> /dev/null || break
        _timeout=3D$(($_timeout-2))
    done
    if [ -n "$_prefix" ]; then
        echo "."
    fi
}

run_rc_command "$1"

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e02150200602151333u5a1bb96aq>