Resin Documentationapp server |
deploying web-applications
Resin's deployment capabilities include clustered deployment, remote deployment, versioning and rollback, command-line deployment, browser deployment, and standard webapps directory filesystem deployment. Resin's .war application deployment can be as simple as copying a .war file to a webapps/ directory on a local machine, and as powerful as cloud deployment, archiving, staging, rollback.
Webapps Directory DeploymentFor a simple deployment, you can copy a .war archive file containing your application to a webapps directory. Resin will detect the .war archive, expand it, and start serving requests. The webapps directory is configured and enabled by the <web-app-deploy/> tag in the resin.xml. <resin xmlns="http://caucho.com/ns/resin"> <cluster id=""> ... <host id=""> <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**"/> </host> </cluster> </resin> The expand-preserve-fileset attribute lets you keep files for a redeployment, which can improve restart times. Normally, Resin will delete all files for an update, including the compiled files for JSP, which forces Resin to recompile JSP files, even if they haven't changed in the update. If you add the expand-preserve-fileset, Resin will only recompile the JSP files that have changed. Command-Line DeploymentCommand-line deployment uses the same resin.xml <web-app-deploy> configuration as a webapps deployment and expands the archive to the same directory. Instead of looking for the .war file in a directory, Resin will look in an internal repository using the web-app's identifier. unix> resinctl deploy test.war The default deployment is to the default host with the war's name as a prefix. Both can be changed with deploy options. Command-Line vs Directory PriorityThe command-line deployment takes priority over the directory deployement, because a deployment to a cluster ensures that all servers have the same version of the application. This means you must undeploy a web-app from the command-line if you decide to switch from command-line deployment to directory deployment. unix> resinctl undeploy test.war unix> cp test.war webapps Deployment ExpansionThe <web-app-deploy> controls the expansion based on web-app ids like "production/webapps/default/test" which is the same as the web-app identifier. The deployment expansion process looks like the following:
The deployment identifier matches the web-app id that Resin logs at startup time. The identifier a repository tag that lets Resin have a general cloud repository system and also handle web-app deployments, versioning, and staging. For the example web-app tag "production/webapp/default/test", the "production" is the deployment stage, "webapp" is because it's a webapp deployment, "default" is the virtual-host name and "test" is the web-app name. Resin deploys a web-application to all servers in the cluster when you deploy using the command-line or the browser. This process happens automatically and does not require any configuration beyond Resin's normal cluster configuration. This cloud deployment does not occur when you deploy using the filesystem by placing a .war in a webapps directory. Cloud deployment only occurs on the command-line or browser. Resin replicates the deployed application to all three triad servers, or to all available server if you have less than three servers. Any server beyond the triad will copy the deployed application from the triad. Normally, you don't need to be aware of the triad, except to make sure at least one of the first three servers is always available. When you add a new dynamic server or restart a server, the server will check with the triad and update to the most recent copy of the application. The system is reliable if servers crash or even if a server crash or network outage occurs during deployment. Since the deployment is transactional, the new version is only activated when every file has been copied and verified on the server. Applications can be activiated independent of their deployment, letting you upload a new deployment to a cloud, and then activating all servers at once or creating a rolling activation. By default, activation is automatic. When an application is deployed, it is automatically activated. You can change the default behavior by setting the startup-mode and redeploy-mode for the web-app-deploy. Startup and Redeploy ModesThe startup-mode is used in a number of places to determine the behaviour of a resource when the server starts. The startup-mode has three values: "automatic", "lazy", and "manual".
The redeploy-mode is used in a number of places to determine the behaviour of a resource when it is replaced or modified while the server is running. The redeploy-mode has two values: "automatic", and "manual".
Deploying to a live server without interruptionIt may be possible to deploy a web application to a live server without interruption to service if certain conditions are met.
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.
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 to upgrade from . A more complicated one might use to upgrade from . The <web-app-deploy> enables versioning: attribute of the<resin xmlns="http://caucho.com/ns/resin"> <cluster id=""> <host id=""> <web-app-deploy path="webapps" versioning="true" expand-preserve-fileset="WEB-INF/work/**"/> </host> </cluster> </resin> Filesystem deployment: Custom web-app with .war fileIn 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
<resin xmlns="http://caucho.com/ns/resin"> <cluster id=""> <host id=""> <web-app id="/foo" root-directory="/var/resin/foo" expand-preserve-fileset="WEB-INF/work/**" archive-path="/usr/local/stage/foo.war"/> </host> </cluster> </resin> Command-Line Remote DeploymentThe "deploy" command deploys a .war file to the default virtual host. In a cloud environment, Resin will copy the deployed .war to all servers in the cluster. Since the com.caucho.security.AdminAuthenticator requires a user and password, you'll need to pass those arguments. unix> resinctl deploy hello.war \ -user foo -password test Browser-based Remote DeploymentAs 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 dynamic server joins the cluster, the triad will populate it with these applications as well. To deploy an application remotely:
|