|
在tomcat使用jsvc实现自动启动遇到了一些问题,虽然jsvc可以运行,但是不能启动tomcat,(tomcat的安装目录属于tomcat用户和tomcat组),不知道是什么原因么??- root@Lee-ubuntu:/etc/init.d# ./tomcat5.sh
- Usage tomcat.sh start/stop
- root@Lee-ubuntu:/etc/init.d# ./tomcat5.sh start
- root@Lee-ubuntu:/etc/init.d#
- 这里什么也不输出,但是jsvc进程确实已经运行了。
复制代码 但是使用tomcat5运行就没有什么问题。- root@Lee-ubuntu:/etc/init.d# ./tomcat5 start
- Starting Tomcat service: Using CATALINA_BASE: /usr/share/tomcat5
- Using CATALINA_HOME: /usr/share/tomcat5
- Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
- Using JRE_HOME: /usr/lib/jvm/java-1.5.0-sun-1.5.0.06
- root@Lee-ubuntu:/etc/init.d#
复制代码 还有一个问题就是tomcat5.sh不能被 sysv-rc-conf识别,所以不知道怎么去实现自动运行,我的shell设计水平有限,现在我有两个文件。你们谁能帮我把tomcat.sh按照 tomcat重新写一边哦? 就是些一个tomcat脚本。实现使用jsvc启动tomcat. 谢谢了~~
文件tomcat.sh- #!/bin/sh
- 1##############################################################################
- #
- # Copyright 2004 The Apache Software Foundation.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # >>http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ##############################################################################
- #
- # Small shell script to show how to start/stop Tomcat using jsvc
- # If you want to have Tomcat running on port 80 please modify the server.xml
- # file:
- #
- # <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
- # <Connector className="org.apache.catalina.connector.http.HttpConnector"
- # port="80" minProcessors="5" maxProcessors="75"
- # enableLookups="true" redirectPort="8443"
- # acceptCount="10" debug="0" connectionTimeout="60000"/>
- #
- # That is for Tomcat-5.0.x (Apache Tomcat/5.0)
- #
- # Adapt the following lines to your configuration
- JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06
- CATALINA_HOME=/usr/share/tomcat5
- DAEMON_HOME=/usr/share/tomcat5
- TOMCAT_USER=tomcat5
- TMP_DIR=/var/tmp
- CATALINA_OPTS=
- CLASSPATH=
- $JAVA_HOME/lib/tools.jar:
- $CATALINA_HOME/bin/commons-daemon.jar:
- $CATALINA_HOME/bin/bootstrap.jar
- case "$1" in start) # # Start Tomcat # $DAEMON_HOME/bin/jsvc-src/jsvc -user $TOMCAT_USER -home $JAVA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$TMP_DIR -outfile $CATALINA_HOME/logs/catalina.out -errfile '&1' $CATALINA_OPTS -cp $CLASSPATH org.apache.catalina.startup.Bootstrap # # To get a verbose JVM #-verbose # To get a debug of jsvc. #-debug ;;
- stop) # # Stop Tomcat # PID=`cat /var/run/jsvc.pid` kill $PID ;;
- *) echo "Usage tomcat.sh start/stop" exit 1;; esac
复制代码
下面是tomcat文件- # This is the init script for starting up the
- # Jakarta Tomcat server
- #
- # chkconfig: 345 91 10
- # description: Starts and stops the Tomcat daemon.
- #
- # Source function library. #. /etc/rc.d/init.d/functions
- # Get config. #. /etc/sysconfig/network
- # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0
- tomcat=/usr/share/tomcat5 startup=$tomcat/bin/startup.sh shutdown=$tomcat/bin/shutdown.sh export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06 export CATALINA_HOME=/usr/share/tomcat5
- start(){ echo -n $"Starting Tomcat service: " $startup RETVAL=$? echo }
- stop(){ action $"Stopping Tomcat service: " $shutdown RETVAL=$? echo }
- status(){ numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l` if [ $numproc -gt 0 ]; then echo "Tomcat is running..." else echo "Tomcat is stopped..." fi }
- restart(){ stop sleep 5 start }
- # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac
- exit 0
复制代码 |
|