blob: f9c2ff3d6b68b3392a8623ee6ecc70db7623b99c (
plain)
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
|
<?xml version="1.0"?>
<project name="test" basedir=".">
<property file="deploy.properties" />
<property name="lock" value="deploy/lock.file" />
<property name="deployDir" value="deploy/${server}" />
<property name="serverPort" value="8080" />
<property name="war" value="demo.war" />
<property name="startupSpawn" value="false" />
<property name="JAVA_HOME" value="/usr/lib/jvm/default-java" />
<property name="waitMinutes" value="3" />
<property name="waitUrl" value="http://localhost:${serverPort}/demo/VAADIN/themes/reindeer/styles.css" />
<property name="shutdownWait" value="10" />
<target name="afterDeploy">
<!-- Empty default -->
</target>
<target name="beforeDeploy">
<!-- Empty default -->
</target>
<target name="deploy">
<antcall target="beforeDeploy" />
<echo message="${server}: Deploying ${war} to ${deployDir}/${autodeployDir}" />
<copy file="${war}" todir="${deployDir}/${autodeployDir}"/>
<antcall target="afterDeploy" />
</target>
<target name="deployStatic">
<unzip src="${war}" dest="${staticDeployDir}">
<patternset>
<include name="VAADIN/**" />
</patternset>
</unzip>
</target>
<target name="unpack-server">
<echo message="${server}: Unpacking ${server}.tar.gz" />
<delete dir="${server}" />
<exec executable="tar">
<arg value="-xf"/>
<arg value="${server}.tar.gz"/>
</exec>
<move file="${server}" tofile="${deployDir}" />
<echo message="Done." />
</target>
<target name="doStartup">
<exec executable="./run.sh" spawn="${startupSpawn}">
<env key="JAVA_HOME" value="${JAVA_HOME}" />
</exec>
</target>
<target name="startup">
<antcall target="doStartup" />
<echo message="${server}: Waiting for ${waitUrl} to become available." />
<waitfor maxwait="${waitMinutes}" maxwaitunit="minute" checkevery="10000" timeoutproperty="timeout">
<http url="${waitUrl}" />
</waitfor>
<!-- Print load averages to get an indicator on whether the server still attempts to start up -->
<exec executable="uptime" />
<fail if="timeout" message="${server} failed to deploy" />
<echo message="${server}: Demo deployed successfully." />
</target>
<target name="shutdown">
<exec executable="./stop.sh" >
<env key="JAVA_HOME" value="${JAVA_HOME}" />
</exec>
<sleep seconds="${shutdownWait}" />
</target>
<target name="force-shutdown">
<exec executable="./cleanup.sh" />
</target>
<target name="check-port">
<fail message="${server}: Something is still listening on port ${serverPort}">
<condition>
<socket server="localhost" port="${serverPort}" />
</condition>
</fail>
</target>
<target name="check-lock">
<available file="${lock}" property="lockAvailable" />
<fail unless="lockAvailable" message="Instance is not locked!" />
</target>
<target name="get-lock">
<mkdir dir="deploy" />
<echo>${server}: Getting the lock</echo>
<exec executable="lockfile" failonerror="true">
<!-- Check every 10 seconds -->
<arg value="-10" />
<!-- Retry for 55 minutes (build server gives up after 60 minutes) -->
<arg value="-r330" />
<arg value="${lock}" />
</exec>
<echo>${server}: Got the lock</echo>
</target>
<target name="clean">
<delete dir="${deployDir}" failonerror="false" />
</target>
<target name="release-lock">
<!-- <exec executable="rm">
<arg value="-f" />
<arg value="${lock}" />
</exec> -->
<delete>
<fileset dir="." includes="${lock}" />
</delete>
<echo>${server}: Released the lock</echo>
</target>
<target name="startup-and-deploy" depends="check-lock,check-port,unpack-server,deploy,startup" />
<target name="shutdown-and-cleanup" depends="shutdown,clean,release-lock,force-shutdown" />
</project>
|