views:

188

answers:

2

Hi All, This is restart target code which is defined in build.xml


target name="restart"

propertycopy name="remote.host" from="deploy.${target.env}.host.${remote.id}"

propertycopy name="remote.port" from="deploy.${target.env}.port.${remote.id}"

sshexec trust="true"
  host="${remote.host}"
  port="${remote.port}"
  username="${scm.user}"
  keyfile="${scm.user.key}"
  command="sudo /usr/local/bin/bounce_jboss"

target


server information is defined in build.properties.

The above code is working fine, but the restarting process is very late bcas its stopping-starting server one and later its stopping-starting another server,

Is there a way where i can restart both servers parallely with a time frame of 45 seconds.

A: 

Have you investigated the Ant Parallel task ? You should be able to parallelise the rebooting fairly simply using this.

e.g.

<parallel>
    <!-- first server reboot -->
    <ssh ...>
    <!-- second server reboot -->
    <ssh ...>
</parallel>
Brian Agnew
Yeah i tried even this way <parallel><sshexec trust="true" host="${remote.host}" port="${remote.port}" username="${scm.user}" keyfile="${scm.user.key}" command="sudo /usr/local/bin/bounce_jboss" /> <sleep seconds="45"/></parallel>
Angrezy
<parallel> will parallelise whatever you contain within it. It doesn't run something in a parallel thread whilst doing the rest of the Ant script.
Brian Agnew
So (briefly) both ssh's need to run under the <parallel> task
Brian Agnew
how to define both ssh's within <parallel>, need to add any condition or loop? Can u give me a example please.
Angrezy
<parallel> <!-- first server reboot --> <ssh ...> <!-- second server reboot --> <ssh ...></parallel>This is not working, each server is restarting two times :-)
Angrezy
A: 

The parallel task will work for you. Another example:

<target name="restart" ... >
    <parallel>
        <!-- first server reboot call -->
        <!-- second server reboot call -->
    </parallel>
</target>

From command line:

>ant restart

Don't execute "ant restart" twice. Only call it once and your servers should only restart once.

Steve
This is how i added:<target name="_restart"><propertycopy name="remote.host" from="deploy.${target.env}.host.${remote.id}"/><propertycopy name="remote.port" from="deploy.${target.env}.port.${remote.id}"/><parallel><sshexec trust="true"host="${remote.host}"port="${remote.port}"username="${scm.user}"keyfile="${scm.user.key}"command="sudo /usr/local/bin/bounce_jboss" /><sleep seconds="30"/><sshexec trust="true"host="${remote.host}"port="${remote.port}"username="${scm.user}"keyfile="${scm.user.key}"command="sudo /usr/local/bin/bounce_jboss" /></parallel> </target>
Angrezy
Actually build is doing a parallel restarts, But due to some clustering problem i want to restrict my restarts to give gap of 30 to 45 seconds between first server restart and second server restart.
Angrezy