配置文件
上一页 主页 上一层 下一页

现在,我们已经按照缺省的配置,跑起来了Resin自带的Web Server。

resin自带的Webserver

那么,我们来看看Resin的WebServer是什么样子的:(Resin的文档里面说它自带的WebServer对于静态页面的服务速度比Apache要快一些)

zixia@zixia.net$ cd /usr/local/resin/bin
zixia@zixia.net$ more httpd.sh
#! /bin/sh
#
# httpd.sh can be called like apachectl
#
# httpd.sh -- execs the web server in the foreground
# httpd.sh start -- starts the web server in the background
# httpd.sh stop -- stops the web server
# httpd.sh restart -- restarts the web server
#!#$#!%$#^%$&Y^%$^@%
!%%$#^$&^&#^@%#!$!@# 有一些注释,值得一看...
!#$T%^%$^$^@%$!#$!#

... ...


exec $perl $bin/wrapper.pl -chdir -name "$name" -class "$class" $args $*

#注意上面这行,是httpd.sh的最后一行。

哇,我说为什么这么厉害,原来是个perl脚本?

zixia@zixia.net$ pwd
/usr/local/resin/bin
zixia@zixia.net
$ cat wrapper.pl
#! /usr/bin/perl
#
# Helpful for getting file path information
use File::Basename;
use Socket;
#...

#!#$#!%$#^%$&Y^%$^@%
!%%$#^$&^&#^@%#!$!@# 有一些注释,值得一看...
!#$T%^%$^$^@%$!#$!#

... ...

    # create a keepalive socket
    # when the wrapper dies, the httpd class will detect that and
    # close gracefully
    $addr = pack("S n a4 x8", AF_INET, 0, "\0\0\0");
    ($name, $aliases, $proto) = getprotobyname('tcp');
    socket(S, AF_INET, SOCK_STREAM, $proto) || die "socket: $!";
    bind(S, $addr) || die "bind: $!";
    $myaddr = getsockname(S);
    ($fam, $port, $addr) = unpack("S n a4 x8", $myaddr);
    listen(S, 5) || die "connect: $!";

    if (fork() == 0) {
        close(S);
        exec("$JAVA_EXE $JAVA_ARGS $class -socketwait $port $conf $RESIN_ARGS 1>> $stdout_log 2>> $stderr_log");
        exit(66);
    }

... ...

原来resin自带的webserver是通过perl来调用他的java程序的...

Resin的配置文件:

<!--
 - The Resin configuration file.
 -
 - This example file is more complicated than is needs to be because
 - it makes several configurations explicit that can be simplified and
 - because it needs to configure the examples.
 -
 - Look in conf/samples for more realistic sample configurations.
 - conf/samples/simple.conf -- a simple, basic configuration
 - conf/samples/deploy.conf -- a simple configuration for deployment
 -
 - The configuration is based on a purely element-based XML.To make
 - it easier to read, attributes can be used as syntactic sugar.
 -
 - The following are equivalent:
 - <foo><bar>13</bar></foo>- canonical representation, but verbose
 - <foo bar=13/> - typical configuration
 - <foo><bar id=13/></foo> - sometimes useful
-->
<!-- Resin的配置文件就是它了:/usr/local/resin/conf/resin.conf,
    - 这个配置文件是XML格式的,要注意如果配置文件中有XML语法错误,
    - resin的XML解释器会抛出异常,resin自然也无法启动。
    -->
<caucho.com> <!-- 配置就是从这个标签开始的 -->

<!-- Resin logging.You can uncomment the following useful log.
 -
 - <log id='/caucho.com/tcp-server'
 -href='stderr:'
 -timestamp='[%H:%M:%S.%s]'/>
-->

<!-- Security providers.Adding JSSE looks like:
 - <security-provider id='com.sun.net.ssl.internal.ssl.Provider'/>
-->

<!-- You can change the compiler to jikes or change the work-dir -->
<!-- 这里!我们安装的jike就可以在这里派上用场 -->
<!-- 注视掉它 java compiler='internal' compiler-args="" work-dir='work'/ -->
<!-- 换成我们C++编写的Jike! -->
<java>
    <compiler>/usr/local/bin/jikes</compiler>
    <compiler-args>-encoding ISO-8859-1</compiler-args>
                <!-- 注意上面的编码,为了显示汉字 -->
    <work-dir>work</work-dir>
</java>

<!--
 - Sample database pool configuration
 - The JDBC name is java:comp/jdbc/test
-->
<dbpool.sql>
    <id>ORCL</id>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    <url>jdbc:oracle:thin:@localhost:1521:SMTH</url>
    <!-- <url>jdbc:oracle:oci8:@SMTH</url> -->
    <!-- 在Linux下面,好像无法使用Java的JDBC胖Driver(OCI8),
        - 因为似乎Oracle8i安装完毕后,提供给JDBC-OCI8 Driver
        - 的JNI的动态连接库libocijdbc8.so是for Solaris的
        -->
    <user>scott</user>
    <password>tiger</password>
    <max-connections>5</max-connections>
</dbpool.sql>
<!--
 - Use precompiled JSP classes if available.
 - 'static-encoding' - optimization if you stick to one character set
-->
<jsp precompile='true' static-encoding='true'/>

<!--
 - For production sites, change class-update-interval to something
 - like 60, so it only checks for updates every minute.
-->
<http-server>
<!--
 - The root file directory of the server.Apache users will change
 - this to /usr/local/apache/htdocs and IIS users will change it
 - to d:\inetpub\wwwroot
-->
<app-dir>doc</app-dir>

<!-- the http port -->
<http port=8080/>

<!-- the srun port, read by both JVM and plugin -->
<srun host='localhost' port='6802'/>

<!--
 - How to add SSL:
 -
 - <http port=8443>
 - <ssl>true</ssl>
 - <key-store-type>pkcs12</key-store-type>
 - <key-store-file>keys/server_cert.p12</key-store-file>
 - <key-store-password>changeit</key-store-password>
 - </http>
-->

<!--
 - Select an error page to display when the connection fails.
 -
 - <error-page location='connection' location='/my-error-page.html'/>
-->

<!-- To disable /caucho-status, set this to false -->
<caucho-status>true</caucho-status>

<!-- how often to check servlets for changes (id used for brevity) -->
<class-update-interval id='2'/>

<!-- maximum number of threads -->
<thread-max>150</thread-max>

<!--
 - How many threads to wait for keepalives.Should be at least the
 - number of Apache processes to get good performance.
-->
<thread-keepalive id=100/>

<!--
 - Enable internal caching.
 - 'size' is the memory size in kb
 - 'entries' is the number of entries in the memory cache
-->
<cache dir='cache' size='1024' entries='1024'/>

<!-- default host if no other host matches -->
<host id=''>
<!--
 - The standalone server should uncomment for access logging.
 - With another web server, like Apache, the web server will
 - log this information.
<access-log id='log/access.log'
format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'/>
-->

<error-log id='log/error.log'/>

<web-app id='/'>
<!--
 - The classpath directive may be repeated.Source is optional
 - Servlets and beans generally belong in WEB-INF/classes
-->
<classpath id='WEB-INF/classes'
 source='WEB-INF/classes'
 compile='true'/>

<!--
 - Expires time for a cacheable file.Production sites will
 - normally change this to '15m'
-->
<cache-mapping url-pattern='/' expires='2s'/>

<!--
 - set the pages to be used as welcome (index) files
-->
<welcome-file-list>index.xtp, index.jsp, index.html</welcome-file-list>

<session-config>
<session-max>4096</session-max>
<session-timeout>30</session-timeout>
<enable-cookies>true</enable-cookies>
<enable-url-rewriting>true</enable-url-rewriting>

<!--
 - Store sessions in the filesystem, so they can persist across
 - servlet and class changes.
 -
 - This may be commented out in deployment for better performance.
-->
<file-store>sessions</file-store>
</session-config>

<!--
 - special mapping so /servlet/pkg.MyServlet invokes pkg.MyServlet
-->
<servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>

<servlet-mapping url-pattern='*.xtp'
 servlet-name='com.caucho.jsp.XtpServlet'/>
<servlet-mapping url-pattern='*.jsp'
 servlet-name='com.caucho.jsp.JspServlet'/>

<!--
 - The following entries configuration the examples.You may safely
 - delete anything from here down.
-->

<!-- Application init parameters, see Env.java to get the values -->
<context-param info='An application information string'/>

<!-- snoop-servlet handles all urls starting with /snoop -->
<servlet-mapping url-pattern='/snoop/*' servlet-name='snoop-servlet'/>

<!-- configure snoop-servlet with init parameters -->
<servlet servlet-name='snoop-servlet' servlet-class='Env'>
<init-param info='A servlet information string'/>
</servlet>

<!-- /~user maps to user directories -->
<path-mapping url-regexp='^/~([^/]*)' real-path='/home/$1/public_html/'/>
</web-app>

<!-- Define applications (ServletContexts) for the examples.
 - Singe applications are entirely separate from one another,
 - including session variables and servlet-mappings, the
 - servlet-mapping declarations need to be repeated.
-->
<web-app id='examples/tags'>
</web-app>

<web-app id='examples/tictactoe'/>

<web-app id='examples/navigation'/>

<web-app id='examples/xsl'/>

<web-app id='examples/templates'>
<servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
<servlet-mapping url-pattern='/GuestJsp' servlet-name='GuestJsp'/>
<servlet-mapping url-pattern='/GuestXtp' servlet-name='GuestXtp'/>
<servlet-mapping url-pattern='/RSS' servlet-name='jsp.RSS'/>

<servlet servlet-name='GuestJsp' servlet-class='jsp.GuestJsp'/>
<servlet servlet-name='GuestXtp' servlet-class='jsp.GuestXtp'/>
</web-app>

<web-app id='/examples/login'/>
</host>
</http-server>
</caucho.com>

我使用的Resin的配置文件:

<caucho.com>
 <log id='/caucho.com/tcp-server'
href='stderr:'
timestamp='[%H:%M:%S.%s]'/>

<java>
<compiler>/usr/local/bin/jikes</compiler>
<compiler-args>-encoding ISO-8859-1</compiler-args>
<work-dir>work</work-dir>
</java>

<dbpool.sql>
<id>ORCL</id>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@localhost:1521:SMTH</url>
<!-- <url>jdbc:oracle:oci8:@SMTH</url> -->
<user>scott</user>
<password>tiger</password>
<max-connections>5</max-connections>
</dbpool.sql>

<jsp precompile='true' static-encoding='true'/>
<http-server>
<app-dir>/webroot</app-dir>
<http port=8080/>
<srun host='localhost' port='6802'/>

<class-update-interval id='2'/>
<thread-max>150</thread-max>
<thread-keepalive id=100/>
<cache dir='cache' size='1024' entries='1024'/>
<host id=''>
<access-log id='log/default-access.log'
format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'/>
<error-log id='log/default-error.log'/>

<web-app id='/'>
<classpath id='WEB-INF/classes'
 source='WEB-INF/classes'
 compile='true'/>
<cache-mapping url-pattern='/' expires='1s'/>
<welcome-file-list>index.xtp, index.jsp, index.html</welcome-file-list>
<session-config>
<session-max>4096</session-max>
<session-timeout>30</session-timeout>
<enable-cookies>true</enable-cookies>
<enable-url-rewriting>true</enable-url-rewriting>
<file-store>sessions</file-store>
</session-config>
<servlet-mapping url-pattern='*.xtp'
 servlet-name='com.caucho.jsp.XtpServlet'/>
<servlet-mapping url-pattern='*.jsp'
 servlet-name='com.caucho.jsp.JspServlet'/>
</web-app>
</host>
</http-server>
</caucho.com>