resin启动两个服务
3,489 views, GameOperation, Linux, 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
下面是详细的配置:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32<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
停止以及重启应用的方式也是一样。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89resin4.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
最后
以上就是听话银耳汤最近收集整理的关于resin 配置多个实例的全部内容,更多相关resin内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复