Linux Mandriva 中自动运行 Tomcat - java.io.IOException:无效参数

Linux Mandriva 中自动运行 Tomcat - java.io.IOException:无效参数

这是我使用的自动运行脚本 -

#!/bin/sh

    # description: Tomcat start/stop script
    # chkconfig:

    TOMCAT_PATH=/java/apache-tomcat-7.0.32/bin
    TOMCAT_START=$TOMCAT_PATH/startup.sh
    TOMCAT_STOP=$TOMCAT_PATH/shutdown.sh

    start()
    {
    if [ -x ${TOMCAT_START} ]; then
    echo "Starting tomcat server..."
    ${TOMCAT_START} &
    else
    echo "Cannot start tomcat server"
    fi
    }

    stop()
    {
    if [ -x ${TOMCAT_STOP} ]; then
    echo "Stopping tomcat server"
    ${TOMCAT_STOP} &
    else
    echo "Cannot stop tomcat server..."
    fi
    }

    restart()
    {
    stop
    sleep 10
    start
    }

    case "$1" in
    'start')
    start
    ;;
    'stop')
    stop
    ;;
    'restart')
    restart
    ;;
    *)
    echo "Please supply an argument [start|stop|restart]"
    esac

我把它放进去——

/etc/rc.d/init.d/

我将其添加到启动中:

/sbin/chkconfig --add --level 345 tomcat

但是当我重新启动系统时,查看日志并看到 -

卡特琳娜.out:

...
INFO: Stopping service Catalina
jan 03, 2013 6:09:04 PM hudson.util.CharacterEncodingFilter destroy
INFO: CharacterEncodingFilter destroyed.
jan 03, 2013 6:09:04 PM javax.jmdns.impl.tasks.state.DNSStateTask run
WARNING: Canceler(www-...-ru.local.).run() exception 
java.io.IOException: Invalid argument
    at java.net.PlainDatagramSocketImpl.send(Native Method)
    at java.net.DatagramSocket.send(DatagramSocket.java:676)
    at javax.jmdns.impl.JmDNSImpl.send(JmDNSImpl.java:1537)
    at javax.jmdns.impl.tasks.state.DNSStateTask.run(DNSStateTask.java:131)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

该过程不会启动。

但如果我执行命令 -

/etc/rc.d/init.d/tomcat start

这个过程开始顺利。

为什么不自动启动?

谢谢!

答案1

我改变了一些 shell 脚本:

#!/bin/sh
#
# Startup script for Tomcat
#

JAVA_HOME="/usr/java/jdk1.7.0_09" ;
JRE_HOME=/usr/java/jdk1.7.0_09/jre;
CATALINA_HOME=/java/tomcat-7.0.27;
export JAVA_HOME && export JRE_HOME &&$CATALINA_HOME/bin/startup.sh &&$CATALINA_HOME/bin/shutdown.sh

case "$1" in
start)
echo -n "Starting Tomcat"
su - tomcat -c $CATALINA_HOME/bin/startup.sh
;;
stop)
echo -n "Stopping Tomcat"
su - tomcat -c $CATALINA_HOME/bin/shutdown.sh
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit 0

然后把它放进去

/etc/rc.d/init.d

添加运行权限:

# chmod +x /etc/init.d/ tomcat

添加了符号链接:

ln -s /etc/init.d/tomcat /etc/rc0.d/K91tomcat
ln -s /etc/init.d/tomcat /etc/rc1.d/K91tomcat
ln -s /etc/init.d/tomcat /etc/rc2.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc3.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc4.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc5.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc6.d/K91tomcat

现在一切都好了。

reboot;

卡特琳娜.out:

...
INFO: Server startup in 113947 ms

多谢!

相关内容