#启动为适配tomcat目录做的准备 #拷贝tomcat必要的配置文件 if [ ! -d "$CATALINA_BASE"/conf ]; then cp -r "$CATALINA_HOME"/conf "$CATALINA_BASE"/ fi if [ ! -d "$CATALINA_BASE"/logs ]; then mkdir logs fi
if [ ! -d "$CATALINA_BASE"/temp ]; then mkdir temp fi
if [ ! -d "$CATALINA_BASE"/webapps ]; then mkdir webapps fi start () { $CATALINA_HOME/bin/startup.sh } stop () { $CATALINA_HOME/bin/shutdown.sh }
status () { SERVER_PID=`cat $CATALINA_PID` if [ ! -n "$SERVER_PID" ]; then echo "服务不在运行" else echo "服务正在运行 pid $SERVER_PID" fi }
restart () { SERVER_PID=`cat $CATALINA_PID` if [ ! -n "$SERVER_PID" ]; then echo $CATALINA_HOME/bin/startup.sh else $CATALINA_HOME/bin/shutdown.sh sleep 3s $CATALINA_HOME/bin/startup.sh fi }
[openlab@qwx366422 servers]$ ll bin total 0 lrwxrwxrwx 1 openlab openlab 54 Dec 23 08:49 activemq -> /wisoft/servers/mq/apache-activemq-5.14.4/bin/activemq lrwxrwxrwx 1 openlab openlab 32 Dec 12 15:44 ark -> /wisoft/servers/ark/wi-tomcat.sh lrwxrwxrwx 1 openlab openlab 33 Dec 12 15:30 igov -> /wisoft/servers/igov/wi-tomcat.sh lrwxrwxrwx 1 openlab openlab 33 Dec 20 16:05 solr -> /wisoft/servers/solr/wi-tomcat.sh
如上,我们就可以在任意位置操作服务了。 比如
1 2 3 4 5 6 7 8 9 10
[openlab@qwx366422 servers]$ igov status 服务正在运行 pid 11189 [openlab@qwx366422 servers]$ igov stop Using CATALINA_BASE: /wisoft/servers/igov Using CATALINA_HOME: /wisoft/tomcat/apache-tomcat-7.0.96 Using CATALINA_TMPDIR: /wisoft/servers/igov/temp Using JRE_HOME: /wisoft/java/jdk1.8.0_231 Using CLASSPATH: /wisoft/tomcat/apache-tomcat-7.0.96/bin/bootstrap.jar:/wisoft/tomcat/apache-tomcat-7.0.96/bin/tomcat-juli.jar Using CATALINA_PID: /wisoft/servers/igov/logs/server.pid Tomcat stopped.