I've used ant to write a deploy task which is parameterized.  Then I can
wrap an iteration task around it and undeploy + deploy on all n Tomcats.

It does depend on 

http://ant-contrib.sourceforge.net/tasks/tasks/foreach.html


    <!-- =================================================================
-->
    <!-- TOMCAT / Deploy / Undeploy    TARGETS
-->
    <!-- =================================================================
-->

    <!-- Deploy the htmout files to all defined application servers.  Will
-->
    <!-- restart the context after deployment is complete.
-->
    <target 
        name="deploy"
        depends="deploy-war-all"
        description="Deploy war to all defined application servers (causes
restart)"/>

    <!-- Don't deploy if no tomcat.instances defined -->
    <condition property="tomcat-deploy-defined">
        <and>
            <isset property="tomcat.instances"/>
        </and>
    </condition>
    
    <!-- Deploy to each defined context by iterating tomcat.instances and
-->
    <!-- farming the real work out to deploy-war-one.
-->
    <target name="deploy-war-all" 
        if="tomcat-deploy-defined"
        description="Restart the context on the tomcat instance(s)">
        <!-- NB: Parallel redeploy is very slow on Tomcat due to the
-->
        <!-- of the cluster deployer.  So, don't use it.
-->
        <foreach
            parallel="false"
            list="${tomcat.instances}"
            delimiter=" "
            param="instance"
            target="deploy-war-one"/>
    </target>

    <!-- Reload the requested context
-->
    <target 
        name="deploy-war-one"
        description="Restart a single context">

        <propertycopy name="tomcat.username"
from="tomcat.${instance}.username" silent="true"/>
        <propertycopy name="tomcat.password"
from="tomcat.${instance}.password" silent="true"/>
        <propertycopy name="tomcat.server"
from="tomcat.${instance}.server"   silent="true"/>
        <propertycopy name="tomcat.port"     from="tomcat.${instance}.port"
silent="true"/>
        <property name="tomcatURL"
value="http://${tomcat.server}:${tomcat.port}${tomcat.manager}"/>

        <fail unless="tomcat.username">Undefined: tomcat.username</fail>
        <fail unless="tomcat.password">Undefined: tomcat.password</fail>
        <fail unless="tomcat.manager" >Undefined: tomcat.manager</fail>
        <fail unless="tomcat.server"  >Undefined: tomcat.server</fail>
        <fail unless="tomcat.port"    >Undefined: tomcat.port</fail>

        <antcall target="deploy-context" inheritall="true"/>
    </target>

    <!-- reload the specified context
-->
    <target
        name="deploy-context"
        description="Reload the given context">
        <fail unless="tomcat.username">Undefined: tomcat.username</fail>
        <fail unless="tomcat.password">Undefined: tomcat.password</fail>
        <fail unless="tomcatURL">Undefined: tomcatURL</fail>
        <echo taskname="deploy-context">
Deploying ${basedir}/${project.war} to ${tomcatURL}
        </echo>
        <undeploy
            failonerror="false"
            taskname="deploy-context"
            username="${tomcat.username}"
            password="${tomcat.password}"
            url     ="${tomcatURL}"
            path    ="/"/>
        <deploy
            taskname="deploy-context"
            username="${tomcat.username}"
            password="${tomcat.password}"
            url     ="${tomcatURL}"
            path    ="/"
            war     ="file:${basedir}/${project.war}"/>
    </target>


Tim

> -----Original Message-----
> From: Kristian Rink [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 31, 2007 9:52 AM
> To: users@tomcat.apache.org
> Subject: Re: tomcat 6, clustering, FarmDeployer
> 
> 
> Filip;
> 
> first off, thanks loads for your hint. So by now I can at least stop
> playing with the FarmWarDeveloper and focus on other things...
> 
> [Filip Hanik - Dev Lists <[EMAIL PROTECTED]> @ Thu, 31 May 2007
> 15:44:59 +0200]
> 
> > hi Kristian, Farm deployer is currently broken, has been for a while
> > and needs to be completely revised.
> 
> Is there another meaningful way of getting an application deployed to a
> tomcat cluster, then, without having to deploy it to each and every
> node? Though this wouldn't be much of a pain (given there just are two
> nodes right now... :) ), it at least reduced comfort and ease-of-use
> compared to the FWD solution...
> 
> Thanks and bye,
> Kristian
> 
> --
> Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
> jab: [EMAIL PROTECTED] * icq: 48874445 * fon: ++49 176 2447 2771
> "One dreaming alone, it will be only a dream; many dreaming together
> is the beginning of a new reality." (Hundertwasser)
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to