Changes between Initial Version and Version 1 of waue/2011/0830


Ignore:
Timestamp:
Aug 30, 2011, 5:06:26 PM (13 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2011/0830

    v1 v1  
     1
     2= 將 tomcat port 開在 80 =
     3
     4以 crawlzilla 為例
     5
     6 * 先安裝 jsvc
     7
     8{{{
     9sudo apt-get install jsvc
     10}}}
     11
     12 * 修改 server.xml 讓 tomcat 運行於 80 port
     13
     14vim /opt/crawlzilla/tomcat/conf/server.xml
     15
     16{{{
     17#!text
     18   <Connector port="80" protocol="HTTP/1.1"
     19               connectionTimeout="20000"
     20               redirectPort="8443" URIEncoding="UTF-8"
     21               useBodyEncodingForURI="true" />
     22}}}
     23
     24 * 修改 sudoers 讓 crawler 可以執行 jsvc
     25
     26sudo vim /etc/sudoers
     27
     28{{{
     29#!text
     30crawler  ALL=NOPASSWD: /opt/crawlzilla/tomcat/bin/startup.sh /opt/crawlzilla/tomcat/bin/shutdown.sh
     31}}}
     32
     33
     34 * 註解掉原本的呼叫方式(最後一行),並再最後面加入兩行用jsvc 驅動的方式
     35
     36sudo vim /opt/crawlzilla/tomcat/bin/startup.sh
     37
     38{{{
     39#!text
     40
     41#exec "$PRGDIR"/"$EXECUTABLE" start "$@"
     42
     43cd /opt/crawlzilla/tomcat
     44
     45sudo /usr/bin/jsvc -home /usr/lib/jvm/java-6-sun -user crawler -pidfile /var/log/crawlzilla/jsvc.pid -cp /opt/crawlzilla/tomcat/bin/bootstrap.jar -outfile /var/log/crawlzilla/jsvc.tomcat.out -errfile /var/log/crawlzilla/jsvc.tomcat.err org.apache.catalina.startup.Bootstrap
     46}}}
     47
     48因此,之後呼叫 /opt/crawlzilla/tomcat/bin/startup.sh 前面都要加 sudo
     49
     50 * 關閉 tomcat
     51
     52sudo vim /opt/crawlzilla/tomcat/bin/shutdown.sh
     53
     54{{{
     55#!text
     56if [ -e /var/log/crawlzilla/jsvc.pid ];then
     57    PID=$(cat /var/log/crawlzilla/jsvc.pid)
     58    kill $PID
     59fi
     60}}}
     61
     62 * vim /opt/crawlzilla/main/tomcat_restart.sh
     63
     64{{{
     65#!text
     66if [ $command == "start" ];then
     67        sudo /opt/crawlzilla/tomcat/bin/startup.sh
     68        debug_info "/opt/crawlzilla/tomcat/bin/startup.sh"
     69elif [ $command == "stop" ];then
     70        sudo /opt/crawlzilla/tomcat/bin/shutdown.sh
     71        debug_info "/opt/crawlzilla/tomcat/bin/shutdown.sh"
     72        kill $tom_pids
     73        debug_info "kill $tom_pids"
     74else
     75        sudo /opt/crawlzilla/tomcat/bin/shutdown.sh
     76        debug_info "/opt/crawlzilla/tomcat/bin/shutdown.sh"
     77        kill $tom_pids
     78        debug_info "kill $tom_pids"
     79        sudo /opt/crawlzilla/tomcat/bin/startup.sh
     80        debug_info "/opt/crawlzilla/tomcat/bin/startup.sh"
     81fi
     82}}}