Caucho Technology
  • resin 4.0
  • packaging/deployment


    Resin provides a wide variety of custom packaging and deployment options.

    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.

    web-app deployment options
    ATTRIBUTEDESCRIPTIONDEFAULT
    archive-pathpath to the .war file which contains the web-app's contents
    dependency-check-intervalhow often Resin should check for changes in the web-app for a redeployment2s
    idunique identifier for the web-app and the default context-path value
    redeploy-check-intervalhow often Resin should check the .war file for changes60s
    redeploy-modehow Resin should handle redeployment: automatic, lazy, or manualautomatic
    root-directorypath to the expanded web-app directoryid as a sub-directory of the virtual-hosts's root
    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>
    

    Startup and Redeploy Modes

    The 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".

    • automatic - starts the resource on server start (default)
    • lazy - starts the resource on the first use
    • manual - waits for JMX to start the resource

    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".

    • automatic - restarts the resource when it is modified (web.xml, *.class, *.war, etc).
    • manual - waits for JMX to restart the resource when changes occur.

    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: 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>
    

    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.

    1. The session objects for your users are being persisted.
    2. The usage of session scoped objects between the old version and the new is compatible.
    3. The usage of application scoped objects between the old version and the new is compatible.
    4. 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.

    1. shutdown primary server(s) (backup server(s) takes over)
    2. deploy new war to primary server(s)
    3. start primary server(s). As soon as the primary server starts, the user will be using the new version of the application.
    4. deploy new war to backup server(s)

    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 dynamic server joins the cluster, the triad will populate it with these applications as well.

    To deploy an application remotely:

    1. 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.
    2. 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".
    3. The application should now be deployed on the server. In a few moments, all the servers in the cluster will have the webapp.

    command line deployment

    Command line deployment capabilities were introduced in Resin 4.0.14. The set of commands allows deploying, undeploying, listing applications deployed on the server and controlling application lifecycle.

    Synopsis of the provided commands and options

    commands
    COMMANDDESCRIPTION
    deploydeploys an application archive
    undeployun-deploys an application specified by a context
    deploy-listlists all applications deployed on a server
    deploy-copycopies an application from one context to another
    start-webappstarts web application context
    stop-webappstops web application context
    restart-webapprestarts web application context
    common options
    ARGUMENTMEANINGDEFAULT
    -confconfiguration fileconf/resin.xml
    -addressip or host name of the servertaken from conf/resin.xml
    -portserver http porttaken from conf/resin.xml
    -useruser name used for authentication to the servernone, required
    -passwordpassword used for authentication to the servernone, required
    -mcommit messagenone, optional

    deploying application

    Deploying an application is done with a deploy command

    java -jar resin.jar [-conf <file>] deploy -user <user> -password <password> [options] <war-file>

    deploying an application from a hello-world.war archive
    java -jar lib/resin.jar deploy -user admin -password secret /projects/hello-world/hello-world.war
    Deployed production/webapp/default/hello-world as hello-world.war to http://127.0.0.1:8080/hmtp
    deploy options
    ARGUMENTMEANINGDEFAULT
    -hostvirtual host to make application available ondefault
    -namename of the context to deploy to, defaults to war-file name[/foo].war
    -stagespecifies stage for staging an applicationproduction
    -versionversion of application formatted as <major.minor.micro.qualifier>none

    listing deployed applications

    Listing deployed applications is done with a deploy-list command

    java -jar resin.jar [-conf <file>] deploy-list -user <user> -password <password>

    java -jar lib/resin.jar deploy-list -user admin -password secret
                        production/webapp/default/hello-world

    copy application from context '/hello-world' to context '/foo'

    Copying an applicaiton is done with a deploy-copy command

    java -jar resin.jar [-conf <file>] deploy-copy -user <user> -password <password> [options]

    java -jar lib/resin.jar deploy-copy -user admin -password secret -source hello-world -target foo
    copied production/webapp/default/hello-world to production/webapp/default/foo
    
    deploy-copy options
    ARGUMENTMEANINGDEFAULT
    -sourcecontext to copy application fromnone
    -source hosthost to copy application fromdefault
    -source-stagesource stageproduction
    -source-versionversion of the source application formatted as <major.minor.micro.qualifier>none
    -targetcontext to copy application tonone
    -target-hosthost to copy an application todefault
    -target-stagetarget stageproduction
    -target-versionversion application to use for a target, formatted as <major.minor.micro.qualifier>none

    undeploying application

    Undeploying an application is done with an undeploy command

    java -jar lib/resin.jar [-conf <file>] undeploy -user <user> -password <password> [options] <name>

    java -jar lib/resin.jar undeploy -user admin -password secret undeploy foo
    Undeployed foo from http://127.0.0.1:8080/hmtp
    undeploy options
    ARGUMENTMEANINGDEFAULT
    -hostvirtual host to make application available ondefault
    -stagespecifies stage for staging an applicationproduction
    -versionversion of application formatted as <major.minor.micro.qualifier>none

    starting application

    Starting an application is done with an start-webapp command

    java -jar resin.jar [-conf <file>] start-webapp -user <user> -password <password> [options] <name>

    start web application deployed at context '/foo'
    java -jar lib/resin.jar start-webapp -user admin -password secret foo
    'production/webapp/default/foo' is started
    start-webapp options
    ARGUMENTMEANINGDEFAULT
    -hostvirtual host to make application available ondefault
    -stagespecifies stage for staging an applicationproduction
    -versionversion of application formatted as <major.minor.micro.qualifier>none

    stopping application

    Stopping an application is done with an stop-webapp command

    java -jar resin.jar [-conf <file>] stop-webapp -user <user> -password <password> [options] <name>

    stop web application deployed at context '/foo'
    java -jar lib/resin.jar stop-webapp -user admin -password secret foo
    'production/webapp/default/foo' is stopped
    stop-webapp options
    ARGUMENTMEANINGDEFAULT
    -hostvirtual host to make application available ondefault
    -stagespecifies stage for staging an applicationproduction
    -versionversion of application formatted as <major.minor.micro.qualifier>none

    restarting application

    Restarting an application is done with an restart-webapp command

    java -jar resin.jar [-conf <file>] restart-webapp -user <user> -password <password> [options] <name>

    stop web application deployed at context '/foo'
    java -jar lib/resin.jar restart-webapp -user admin -password secret foo
    'production/webapp/default/foo' is restarted
    restart-webapp options
    ARGUMENTMEANINGDEFAULT
    -hostvirtual host to make application available ondefault
    -stagespecifies stage for staging an applicationproduction
    -versionversion of application formatted as <major.minor.micro.qualifier>none

    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: 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:DeployService/>
    
        ...
      </cluster>
    </resin>
    

    The second step is adding at least one administration user, so only authorized administrators can update the server. The <resin:AdminAuthenticator> 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.


    Copyright © 1998-2011 Caucho Technology, Inc. All rights reserved.
    Resin ® is a registered trademark, and Quercustm, Ambertm, and Hessiantm are trademarks of Caucho Technology.