`

resin上跑第一个web实例

    博客分类:
  • web
阅读更多
刚刚成功试过resin启动,默认的root是resin的doc和admin的一个index页面。
现在想移植一个tomcat的web实例到resin来。于是想找eclipse的resin插件,结果发现不支持resin3.1, 再找了找还真没找到了。
没办法, 看看怎样直接在eclipse中用命令行运行好了。这倒好, resin的主页上有提供这个方法的教学:
http://wiki.caucho.com/IDE
引用
Starting Resin from within the IDE
Resin is started and stopped by the IDE. Console messages appear in the console window of the IDE.
IDE configuration value description
Classpath all of the jars in resin.home/lib, see Global Library|
Java argument -Djava.system.class.loader=com.caucho.loader.SystemClassLoader
Main class com.caucho.server.resin.Resin
Program argument -conf conf/development.conf See development.conf
Program argument -server-root /path/to/webapp The location of the web-app
[edit] Additional configuration

Some systems require additional configuration, indicated by Resin error messages.
IDE configuration value description
Classpath java.home/lib/tools.jar Needed for compiling java files
Java argument -Dresin.home=/usr/local/resin Needed if Resin cannot discover the value programmatically

整理一下,应该是这样的
resin运行需要指定三个参数:root、conf、resin.home,
而root和resin.home应当都是同一个位置,就是resin安装的根目录
而conf默认的是resin.home/conf/resin.conf, 这个会根据每个web应用不同,因此往往需要创建一个。
1) classpath中要把resin.home/lib下面的所有jar包添加进来
2)运行的主程序是com.caucho.server.resin.Resin
3)通过jvm参数指定resin.home, -Dresin.home=/usr/local/resin;
     主程序参数指定root和conf:-conf conf/development.conf
                                             -server-root /path/to/webapp
4)添加jvm参数:-Djava.system.class.loader=com.caucho.loader.SystemClassLoader
经过我的实验, root实际上可以不指定。

这个conf比较重要, 官方的wiki推荐我们使用http://wiki.caucho.com/Development.conf,我把内容贴出来,注意看里面的注释:
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">

  <resin:set var="http.port" default="8080"/>
  <resin:set var="log.level" default="fine"/>

  <log path="stdout:">
    <logger name="" level="${Var['log.level']}"/>
  </log>

  <server>
    <class-loader>
      <tree-loader path="${resin.home}/lib"/>
    </class-loader>

    <http server-id="" host="*" port="${Var['http.port']}"/>

    <dependency-check-interval>2s</dependency-check-interval>

    <javac compiler="internal" args=""/>

    <resin:import path="${resin.home}/conf/app-default.xml"/>

    <resin:if test="${resin.isProfessional()}">
      <cache path="WEB-INF/work/cache" memory-size="8M"/>
    </resin:if>

    <web-app-default>
      <cache-mapping url-pattern="/" expires="5s"/>
      <cache-mapping url-pattern="*.gif" expires="60s"/>
      <cache-mapping url-pattern="*.jpg" expires="60s"/>

      <allow-servlet-el/>
    </web-app-default>

    <host id="">
      <web-app id="/"><!--这里可以加你的host, 可能是像下面这样-->
<!--<web-app id='/myprojectName' document-directory="d:\myprojectName\webapp"> -->
        <session-config>
          <file-store>WEB-INF/work/sessions</file-store>
        </session-config>
      </web-app>
    </host>
  </server>
</resin>

里面加了些注释的地方,说的是如何设定web应用的context和path
这里面还可以设置日志级别以及resin启动的端口
对于log的设定可以参考:
http://www.caucho.com/resin-3.0/config/log.xtp#stdout-log
实际上resin的log就是基于JDK logging interface
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics