티스토리 뷰
728x90
출처 : RHEL/CentOS tomcat7 init.d service script. · GitHub
tomcat 서비스 스크립트 작성
$ sudo vi /etc/init.d/tomcat
tomcat 내용
#!/bin/sh # # /etc/init.d/tomcat7 -- startup script for the Tomcat 7 servlet engine # # Written by Miquel van Smoorenburg . # Modified for Debian GNU/Linux by Ian Murdock . # Modified for Tomcat by Stefan Gybas . # Modified for Tomcat6 by Thierry Carrez . # Modified for Tomcat7 by Ernesto Hernandez-Novich . # Additional improvements by Jason Brittain . # ### BEGIN INIT INFO # Provides: tomcat7 # 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. # sudo update-rc.d tomcat defaults # sudo update-rc.d tomcat remove # ls /etc/rc0.d ### END INIT INFO set -e ## Source function library. #. /etc/rc.d/init.d/functions export PROCESS_NAME=tomcat-real export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el6_9.x86_64 export JAVA_OPTS="-Dfile.encoding=UTF-8 \ -Dcatalina.logbase=/var/log/tomcat \ -Dnet.sf.ehcache.skipUpdateCheck=true \ -XX:+DoEscapeAnalysis \ -XX:+UseConcMarkSweepGC \ -XX:+CMSClassUnloadingEnabled \ -XX:+UseParNewGC \ -Xms1024m -Xmx2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+DisableExplicitGC" export PATH=$JAVA_HOME/bin:$PATH export TOMCAT_USER=root export TOMCAT_HOME=/opt/tomcat export SHUTDOWN_WAIT=20 tomcat_pid() { echo `ps aux | grep ${PROCESS_NAME} | grep -v grep | awk '{ print $2 }'` } start() { pid=$(tomcat_pid) if [ -n "$pid" ] then echo "Tomcat is already running (pid: $pid)" else # Start tomcat echo "Starting tomcat" ulimit -n 100000 umask 007 /bin/su - $TOMCAT_USER -c "$TOMCAT_HOME/bin/startup.sh -Dprocessname=${PROCESS_NAME}" fi return 0 } stop() { pid=$(tomcat_pid) if [ -n "$pid" ] then echo "Stoping Tomcat" /bin/su - $TOMCAT_USER -c $TOMCAT_HOME/bin/shutdown.sh let kwait=$SHUTDOWN_WAIT count=0; until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ] do echo -n -e "\nwaiting for processes to exit"; sleep 1 let count=$count+1; done if [ $count -gt $kwait ]; then echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n" kill -9 $pid fi else echo "Tomcat is not running" fi return 0 } case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) pid=$(tomcat_pid) if [ -n "$pid" ] then echo "Tomcat is running with pid: $pid" else echo "Tomcat is not running" fi ;; esac exit 0
tomcat 파일 실행권한 부여
$ sudo chmod u+x /etc/init.d/tomcat
tomcat 서비스 등록
$ sudo chkconfig --add tomcat
tomcat 서비스 삭제
$ sudo chkconfig --del tomcat
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- JavaScript
- Linux
- KOBA
- 서울오토살롱
- Mac
- 전예희
- Delphi Tip
- 송주경
- 일본여행
- Xcode
- android
- 레이싱모델 익스트림 포토 페스티벌
- Spring MVC
- BPI-M4
- 튜닝쇼 2008
- 동경
- Delphi
- flex
- 지스타2007
- Java
- ubuntu
- ble
- Spring
- NDK
- ffmpeg
- sas2009
- koba2010
- MySQL
- oracle
- SAS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함