resin 配置多个实例

resin启动两个服务

3,489 views, GameOperationLinux, by 木木.

此配置适用于3.1.16并经过测试
Resin 运行起来后,一般有这么几个端口
1. WatchDog 的端口,默认6600
2. Server 监控端口,默认6800
3. 应用的HTTP端口,默认8080
不管有多少个应用,Resin只会启动一个WatchDog 实例。
本文所说的并不是通过不同的url前缀来配置不同的应用,我们希望具有如下效果
访问 http://localhost:8081/ 对应的是Web应用1
访问 http://localhost:8082/ 对应的是Web应用2
或者可能是同一个应用,但是两个或者多个端口都可以访问,这在应用的集群中是非常有用的。
首先Resin中每个应用会占用一个HTTP端口以及一个Server监控端口,假设有两个应用,我们事先分配好端口分别是:
Web1:8081,6801
Web2:8082,6802
下面是详细的配置:

<resin xmlns=http://caucho.com/ns/resin
       xmlns:resin=http://caucho.com/ns/resin/core>
  <log name="" level="info" path="stdout:"/>
  <cluster id="web1">
    <server-default>
      <jvm-arg>-Xmx1024m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-server</jvm-arg>
    </server-default>   
    <resin:import path="${resin.home}/conf/app-default.xml"/>
    <server id="web1" port="6801">
      <http id="" port="8081"/>
    </server>
    <host id="" root-directory=".">
      <web-app id="/" root-directory="D:/WORKDIR/web1" redeploy-mode="manual"/>
    </host>
  </cluster>
 
  <cluster id="web2">
    <server-default>
      <jvm-arg>-Xmx1024m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-server</jvm-arg>
    </server-default>   
    <resin:import path="${resin.home}/conf/app-default.xml"/>
    <server id="web2" port="6802">
      <http id="" port="8082"/>
    </server>
    <host id="" root-directory=".">
      <web-app id="/" root-directory="D:/WORKDIR/web2/webapp" redeploy-mode="manual"/>
    </host>
  </cluster>
</resin>


上面的配置中,我们为每个应用分配一个唯一的 server id,分别是 web1 和 web2
要启动这两个应用,命令是
httpd start -server web1
httpd start -server web2
停止以及重启应用的方式也是一样。



resin4.0 配置多个实例

<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">
 
  <log-handler name="" level="all" path="stdout:"
               timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "/>
 
  <logger name="com.caucho" level="info"/>
 
  <logger name="com.caucho.java" level="config"/>
  <logger name="com.caucho.loader" level="config"/>
 
  <class-loader>
    <tree-loader path="${resin.root}/ext-lib"/>
  </class-loader>
 
  <resin:AdminAuthenticator>
    <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
  </resin:AdminAuthenticator>
 
  <dependency-check-interval>2s</dependency-check-interval>
 
  <system-property mail.smtp.host="127.0.0.1"/>
  <system-property mail.smtp.port="25"/>
 
  <cluster-default>
    <resin:import path="${__DIR__}/app-default.xml"/>
 
    <development-mode-error-page/>
 
    <resin:if test="${resin.professional}">
      <cache memory-size="64M">
        <rewrite-vary-as-private/>
      </cache>
    </resin:if>
 
    <resin:DeployService/>
 
    <resin:if test="${resin.professional}">
      <resin:AdminServices/>
    </resin:if>
 
    <host-default>
      <access-log path="log/access.log" 
                format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
                rollover-period="1W"/>
 
      <web-app-deploy path="webapps" versioning="true"/>
 
      <web-app-default>
        <prologue>
          <allow-servlet-el/>
        </prologue>
 
        <session-config>
          <use-persistent-store/>
          <enable-url-rewriting>false</enable-url-rewriting>
        </session-config>
 
        <resin:if test="${resin.professional}">
          <cache-mapping url-pattern="/" max-age="5s"/>
          <cache-mapping url-pattern="*.gif" max-age="60s"/>
          <cache-mapping url-pattern="*.jpg" max-age="60s"/>
          <cache-mapping url-pattern="*.png" max-age="60s"/>
          <cache-mapping url-pattern="*.css" max-age="60s"/>
          <cache-mapping url-pattern="*.js" max-age="60s"/>
         </resin:if>
      </web-app-default>
    </host-default>
  </cluster-default>
 
 
  <cluster id="web1">
    <root-directory>.</root-directory>
    <server-default>
      <!-- The http port -->
      <http address="*" port="8080"/>
    </server-default>
    <!-- define the servers in the cluster -->
    <server id="web1" address="127.0.0.1" port="6800">
    </server>
    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <web-app id="/" root-directory="/www/webroot/WebRoot/"/>
    </host>
  </cluster>
 
 
  <cluster id="web2">
    <root-directory>.</root-directory>
    <server-default>
      <!-- The http port -->
      <http address="*" port="8081"/>
    </server-default>
    <!-- define the servers in the cluster -->
    <server id="web2" address="127.0.0.1" port="6801">
    </server>
    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <web-app id="/" root-directory="/wwwgift/webroot/WebRoot/"/>
    </host>
  </cluster>
</resin>
上面的配置中,我们为每个应用分配一个唯一的 server id,分别是 web1 和 web2
要启动这两个应用,命令文件在resin的bin目录中


resin.sh start -server web1
resin.sh start -server web2


resin.sh stop -server web1
resin.sh stop -server web2



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值