-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.xml
226 lines (206 loc) · 8.3 KB
/
server.xml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<project name="server" basedir="./" xmlns:antcontrib="antlib:net.sf.antcontrib">
<target name="get.server.log.dir">
<antcontrib:trycatch>
<try>
<antcontrib:runtarget target="${server.type}.server.log.dir" />
</try>
<catch>
</catch>
</antcontrib:trycatch>
</target>
<property name="server.deploy.dir" location="${war.target.dir}/../"/>
<property name="server.host" value="localhost"/>
<property name="server.ip" value="127.0.0.1"/>
<property name="server.port" value="8088"/>
<property name="server.port.http" value="8088"/>
<property name="server.port.ajp" value="8009"/>
<property name="server.dir" location="${basedir}/../server/${server.type}" />
<property name="server.log.dir" value="${log.dir}"/>
<property name="server.type" value="runwar" />
<property name="server.charset" value="UTF-8" />
<property name="server.url" value="http://${server.host}:${server.port.http}${war.contextpath}/index.cfm" />
<property name="deploy.remote.unzip.cmd" value="/usr/bin/unzip"/>
<property name="deploy.remote.keyfile" value=""/>
<property name="deploy.remote.dir" value="./"/>
<property name="server.memory.max" value="256M"/>
<property name="server.memory.perm" value="64M"/>
<property name="server.memory.perm.max" value="${server.memory.perm}"/>
<property name="server.java.opts" value=""/>
<property name="server.gc" value=""/>
<!-- -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000 -->
<property name="server.jvm.args" value="-XX:+HeapDumpOnOutOfMemoryError -Xms${server.memory.max} -Xmx${server.memory.max} -XX:PermSize=${server.memory.perm} -XX:MaxPermSize=${server.memory.perm.max} ${server.gc} -Djava.net.preferIPv4Stack=true ${server.java.opts}" />
<property name="jboss.version.major" value="7.1" />
<antcontrib:if>
<equals arg1="${jboss.version.major}" arg2="7.1" />
<then>
<import file="containers/jboss/jboss7.xml" />
</then>
<else>
<import file="containers/jboss/jboss.xml" />
</else>
</antcontrib:if>
<import file="containers/tomcat/tomcat.xml" />
<import file="containers/winstone/winstone.xml" />
<import file="containers/jetty/jetty.xml" />
<import file="containers/resin/resin.xml" />
<import file="containers/glassfish/glassfish.xml" />
<import file="containers/runwar/runwar.xml" />
<target name="server.etc.hosts">
<antcontrib:switch value="${os.name}">
<case value="Mac OS X">
<property name="etc.hosts.file" value="/etc/hosts"/>
</case>
<case value="Linux">
<property name="etc.hosts.file" value="/etc/hosts"/>
</case>
<case value="Windows">
<property environment="env"/>
<property name="etc.hosts.file" value="${env.SystemRoot}\System32\drivers\etc\hosts" />
<echo message="${etc.hosts.file}" />
</case>
<case value="Windows 7">
<property environment="env"/>
<property name="etc.hosts.file" value="${env.SystemRoot}\System32\drivers\etc\hosts" />
<echo message="${etc.hosts.file}" />
</case>
<default>
<fail message="Um, the os '${os.name}' is unknown to me, esse!" />
</default>
</antcontrib:switch>
<replaceregexp byline="false" file="${etc.hosts.file}" flags="msi">
<regexp pattern="^${server.ip}[\s]+${server.host}[\s]?$" />
<substitution expression="" />
</replaceregexp>
<echo file="${etc.hosts.file}" append="true"><![CDATA[${server.ip} ${server.host}]]>${line.separator}</echo>
</target>
<target name="server.processes">
<sequential>
<requires-ext resource="/ext/containers/util/" />
<echoproperties prefix="deploy"/>
<exec executable="sh" osfamily="unix">
<arg value="-c"/>
<arg value="ps aux | grep 'java\|tomcat\|jetty'"/>
</exec>
<exec executable="tasklist" osfamily="windows">
<arg value="/FI"/>
<arg value="IMAGENAME eq java.exe"/>
</exec>
</sequential>
</target>
<macrodef name="sshexec-server">
<attribute name="command" />
<attribute name="host" />
<attribute name="username" />
<attribute name="passphrase"/>
<attribute name="keyfile" default=""/>
<attribute name="port" />
<sequential>
<echo message="com: @{command}" />
<sshexec verbose="false"
command="@{command}"
host="@{host}"
username="@{username}"
passphrase="@{passphrase}"
keyfile="@{keyfile}" trust="true" port="@{port}" />
</sequential>
</macrodef>
<macrodef name="server-run">
<attribute name="port" default="0" description="only works for runwar ATM"/>
<attribute name="stop-port" default="0" description="only works for runwar ATM"/>
<attribute name="war" default="${war.target.dir}" description="only works for runwar ATM"/>
<element name="stuff" implicit="true"/>
<sequential>
<antcontrib:var name="runwar.port.orig" value="${runwar.port}" />
<antcontrib:var name="runwar.port" value="@{port}" />
<antcontrib:var name="runwar.stop.socket.orig" value="${runwar.stop.socket}" />
<antcontrib:var name="runwar.stop.socket" value="@{stop-port}" />
<antcontrib:var name="war.target.dir.orig" value="${war.target.dir}" />
<antcontrib:var name="war.target.dir" value="@{war}" />
<antcontrib:runtarget target="server.start" />
<antcontrib:trycatch property="_erredesse">
<try>
<stuff />
</try>
<catch>
<property name="server-run.failed" value="true"/>
<echo message="something erred esse! ${_erredesse}"/>
<server-log-tail />
</catch>
</antcontrib:trycatch>
<antcontrib:runtarget target="server.stop" />
<antcontrib:var name="runwar.port" value="${runwar.port.orig}" />
<antcontrib:var name="runwar.stop.socket" value="${runwar.stop.socket.orig}" />
<antcontrib:var name="war.target.dir" value="${war.target.dir.orig}" />
<fail if="server-run.failed" message="something erred esse! ${_erredesse}" />
</sequential>
</macrodef>
<macrodef name="server-log-tail">
<attribute name="dir" default="${server.log.dir}" />
<attribute name="lines" default="30" />
<sequential>
<antcontrib:if>
<available file="@{dir}"/>
<then>
<antcontrib:for param="file">
<fileset dir="@{dir}" includes="*.log"/>
<sequential>
<echo message="*** last @{lines} lines from @{file} ***" />
<antcontrib:var name="logfile.tail" unset="true" />
<loadfile srcfile="@{file}" property="logfile.tail">
<filterchain>
<tailfilter lines="@{lines}"/>
</filterchain>
</loadfile>
<echo message="${logfile.tail}"/>
</sequential>
</antcontrib:for>
</then>
<else>
<echo message="server.log.dir does not exist: @{dir}" />
</else>
</antcontrib:if>
</sequential>
</macrodef>
<target name="server.log.tail" depends="get.server.log.dir">
<server-log-tail />
</target>
<target name="server.install" description="installs ${server.type} server">
<antcontrib:runtarget target="${server.type}.install" />
</target>
<target name="server.uninstall" description="uninstalls ${server.type} server">
<antcontrib:runtarget target="${server.type}.uninstall" />
</target>
<target name="server.configure" description="configure ${server.type} server">
<antcontrib:runtarget target="${server.type}.configure" />
</target>
<target name="server.start.fg" description="starts ${server.type} server in foreground">
<antcontrib:var name="background" value="false" />
<antcontrib:runtarget target="${server.type}.start" />
</target>
<target name="server.start" description="starts ${server.type} server">
<antcontrib:runtarget target="${server.type}.start" />
</target>
<target name="server.stop" description="stop ${server.type} server">
<antcontrib:runtarget target="${server.type}.stop" />
</target>
<target name="server.restart" description="restarts ${server.type} server">
<antcontrib:runtarget target="${server.type}.stop" />
<antcontrib:runtarget target="${server.type}.start" />
</target>
<target name="server.deploy" description="deploys war to ${server.type} server">
<copy todir="${server.deploy.dir}/${war.name}.war">
<fileset dir="${war.target.dir}">
<include name="**" />
</fileset>
</copy>
</target>
<target name="gae.deploy" description="deploys war to GAE">
<exec executable="${gae.appconfig.executable}" output="gae.deploy.log">
<arg value="update"/>
<arg value="${war.target.dir}"/>
</exec>
<loadfile srcfile="gae.deploy.log" property="gae.deploy.log">
</loadfile>
<echo message="${gae.deploy.log}"/>
</target>
</project>