Deploy
From Resin 3.0
<document> <header> <product>resin</product> <title>Packaging/Deployment</title> <description>
Resin provides a wide variety of custom packaging and deployment options.
</description> </header>
<body>
<localtoc/>
<s1 title="See Also">
- <a href="../reference/webapp-tags.xtp">web-app tags</a> defines all of the available tags for web-app configuration.
- <a href="../reference/host-tags.xtp">host tags</a> defines all of the available tags for host configuration.
</s1>
<s1 title="Custom web-app with .war file">
In this scenario, you want to configure a web-app with a specific root-directory and specify the location of the .war file. As usual, when Resin sees any changes in the .war file, it will expand the new data into the root-directory and restart the web-app. This capability, gives sites more flexibility where their directories and archive files should be placed, beyond the standard webapps directory.
The optional archive-path
argument of the
<web-app> will point to the .war file to be expanded.
<deftable title="web-app deployment options"> <tr>
<th>Attribute</th> <th>Description</th> <th>Default</th>
</tr> <tr>
<td>archive-path</td> <td>path to the .war file which contains the web-app's contents</td> <td></td>
</tr> <tr>
<td>dependency-check-interval</td> <td>how often Resin should check for changes in the web-app for a redeployment</td> <td>2s</td>
</tr> <tr>
<td>id</td> <td>unique identifier for the web-app and the default context-path value</td> <td></td>
</tr> <tr>
<td>redeploy-check-interval</td> <td>how often Resin should check the .war file for changes</td> <td>60s</td>
</tr> <tr>
<td>redeploy-mode</td> <td>how Resin should handle redeployment: automatic, lazy, or manual</td> <td>automatic</td>
</tr> <tr>
<td>root-directory</td> <td>path to the expanded web-app directory</td> <td>id as a sub-directory of the virtual-hosts's root</td>
</tr> </deftable>
<example title="Example: resin.xml for custom web-app"> <resin xmlns="http://caucho.com/ns/resin"> <cluster id="">
<host id="">
<web-app id="/foo" root-directory="/var/www/foo" archive-path="/usr/local/stage/foo.war"/>
</host>
</cluster> </resin> </example>
</s1>
<s1 title="web-app versioning">
Resin can deploy multiple versions of a web-app simultaneously, simplifying any application upgrades. The old version of the web-app will continue to receive old sessions, while the new version will get the new requests. So any user will see a consistent version as the web site update occurs with no downtime required.
The versioning requires <web-app-deploy>, i.e. it works with the webapps directory. The versioning is numerically-based, allowing dotted notation, to determine the most recent version. A simple deployment process might use foo-101 to upgrade from foo-100. A more complicated one might use foo-10.3.14 to upgrade from foo-10.3.13.
The versioning attribute of the <web-app-deploy> enables versioning:
<example title="Example: resin.xml for webapps versioning"> <resin xmlns="http://caucho.com/ns/resin"> <cluster id=""> <host id="">
<web-app-deploy path="webapps" versioning="true"/>
</host> </cluster> </resin> </example>
</s1>
<s1 title="Deploying to a live server without interruption">
It may be possible to deploy a web application to a live server without interruption to service if certain conditions are met.
- The session objects for your users are being persisted.
- The usage of session scoped objects between the old version and the new is compatible.
- The usage of application scoped objects between the old version and the new is compatible.
- Database schema changes are not required.
Resin allows you to have a backup instance running. The idea is that this backup instance of Resin takes over if your primary Resin instance goes down.
If you are using a load balancer to distribute your load to multiple primary servers, each primary server has a backup server.
You can use this feature to deploy to a live server without interruption of service.
- shutdown primary server(s) (backup server(s) takes over)
- deploy new war to primary server(s)
- start primary server(s). As soon as the primary server starts,
the user will be using the new version of the application.
- deploy new war to backup server(s)
</s1>
<s1 title="Browser-based Remote Deployment">
As of Resin 4.0.0, it is now possible to deploy web applications remotely to a shared repository that is distributed across the cluster. This feature allows you to deploy once to any triad server and have the application be updated automatically across the entire cluster. When a new <a href="dynamic-servers.xtp">dynamic server</a> joins the cluster, the triad will populate it with these applications as well.
To deploy an application remotely:
- log into the resin-admin console on any triad server. Make sure you are connecting over SSL, as this feature is not available over a non-encrypted channel.
- Browse to the "webapp" tab of the resin-admin server and at the bottom of the page, enter the virtual host, URL, and local .war file specifying the web application, then press "Deploy". <figure src="deploy-webapp.png"/>
- The application should now be deployed on the server. In a few moments, all the servers in the cluster will have the webapp. <figure src="deployed-webapp.png"/>
</s1>
<s1 title="ant/maven Remote Deployment">
With remote deployment, you can use an ant or maven task to deploy a .war file to a running Resin instance. This will require some configuration of the resin.xml to enable deployment. For security reasons, remote deployment and administration is disabled by default, so you will need to enable the features to use them.
- Enable remote administration (the HMTP service).
- Add at least one admin user in AdminAuthenticator.
- Enable the remote deploy service.
The first step is enabling remote administration, so you can manage the server remotely, either with eclipse, or ant, or maven. If disabled, Resin will ignore all remote administration requests. The disabled error message will be something like "Failed to connect to HMTP because HMTP service has not been enabled." In the resin.xml, the <resin:RemoteAdminService> tag enables remote administration:
<example title="Example: resin.xml enable remote administration"> <resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin"> ...
<resin:AdminAuthenticator> <resin:user name="harry" password="..."/> </resin:AdminAuthenticator> <cluster id=""> <resin:RemoteAdminService/> <resin:RemoteDeploy/>
... </cluster>
</resin> </example>
The second step is adding at least one administration user, so only authorized administrators can update the server. The <a href="security.xtp"><resin:AdminAuthenticator></a> tag configures administrators. If no administrators are added, Resin will reject any remote administration requests.
The third step is enabling the deploy service itself with the <resin:DeployService> tag. The deploy service is responsible for managing uploads of new applications and distributing them to the servers in the cluster.
When troubleshooting, it's helpful to know that Resin uses BAM/HMTP to connect the deployment client with the deployment server. The <resin:RemoteAdminService> enables BAM/HMTP. If the server is down or the remote admin service isn't enabled, the error messages will complain that the BAM/HMTP connection is not allowed.
</s1>
</body> </document>