1. 程式人生 > >配置resin4多實例

配置resin4多實例

resin

Resin 運行起來後,一般有這麽幾個端口

  1. WatchDog 的端口,默認6600
  2. Server 監控端口,默認6800
  3. 應用的HTTP端口,默認8080
    不管有多少個應用,Resin只會啟動一個WatchDog 實例。

首先Resin中每個應用會占用一個HTTP端口以及一個Server監控端口,假設有兩個應用,我們分配的端口分別是:
app1:8010,6801
app2:8020,6802

下面是詳細的配置:

  <cluster id="app1">

    <server-default>
        <jvm-arg>-Xms512m</jvm-arg>
        <jvm-arg>-Xmx512m</jvm-arg>
        <jvm-arg>-Xmn128m</jvm-arg>
        <jvm-arg>-XX:PermSize=64m</jvm-arg>
        <jvm-arg>-XX:MaxPermSize=128m</jvm-arg>
        <thread-max>512</thread-max>
        <socket-timeout>30s</socket-timeout>
        <keepalive-max>512</keepalive-max>
        <keepalive-timeout>60s</keepalive-timeout>
    </server-default>
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app1-" address-list="127.0.0.1" port="6801">
       <http address="192.168.30.10" port="8010"/>
    </server-multi>

    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
    <web-app id="/" character-encoding=‘UTF-8‘ document-directory="/data/project/app1/ROOT" archive-path="/data/project/app1/ROOT.war">
                <form-parameter-max>100</form-parameter-max>
                <stderr-log path=‘/data/logs/app1/stderr.log‘ timestamp=‘[%Y-%m-%d %H:%M:%S] ‘ rollover-period=‘1D‘/>
                <stdout-log path=‘/data/logs/app1/stdout.log‘ timestamp=‘[%Y-%m-%d %H:%M:%S] ‘ rollover-period=‘1D‘/>
        </web-app>
    </host>
  </cluster>

  <cluster id="app2">

    <server-default>
        <jvm-arg>-Xms512m</jvm-arg>
        <jvm-arg>-Xmx512m</jvm-arg>
        <jvm-arg>-Xmn128m</jvm-arg>
        <jvm-arg>-XX:PermSize=64m</jvm-arg>
        <jvm-arg>-XX:MaxPermSize=128m</jvm-arg>
        <thread-max>512</thread-max>
        <socket-timeout>30s</socket-timeout>
        <keepalive-max>512</keepalive-max>
        <keepalive-timeout>60s</keepalive-timeout>
    </server-default>

    <server-multi id-prefix="app2-" address-list="127.0.0.1" port="6802">
       <http address="192.168.30.10" port="8020"/>
    </server-multi>

    <host id="" root-directory=".">
      <!--
                    - webapps can be overridden/extended in the resin.xml
        -->
    <web-app id="/" character-encoding=‘UTF-8‘ document-directory="/data/project/app2/ROOT" archive-path="/data/project/app2/ROOT.war">
                <form-parameter-max>100</form-parameter-max>
                <stderr-log path=‘/data/logs/app2/stderr.log‘ timestamp=‘[%Y-%m-%d %H:%M:%S] ‘ rollover-period=‘1D‘/>
                <stdout-log path=‘/data/logs/app2/stdout.log‘ timestamp=‘[%Y-%m-%d %H:%M:%S] ‘ rollover-period=‘1D‘/>
        </web-app>
     </host>
  </cluster>

上面的配置中,我們為每個應用分配一個唯一的 server id,分別是 app1 和 app2
要啟動這兩個應用,命令文件在resin的bin目錄中

resin.sh start -server app1-0  
resin.sh start -server app2-0  

停止命令:

resin.sh stop -server app1-0  
resin.sh stop -server app2-0  

配置resin4多實例