The post on CruiseControl's Confluence maybe easier to follow
(http://confluence.public.thoughtworks.org/display/CC/Running+Servertest
s+with+Ant), but basically you use the script as a wrapper to call
yours.  I actually added the 'ANTRUN_OUTPUT' variable to the wrapper
script and just execute an ssh command.

So, 'antRunAsync.sh':
#!/bin/sh
 # antRunAsync - Wrapper script to run an executable detached in the
 # background from Ant's <exec> task.  This works be redirecting stdin,
 # stdout and stderr so Ant finds them closed and doesn't wait for the
 # program to exit.
 #
 # usage:
 # <exec executable="antRunAsync.sh" failonerror="yes">
 #   <env key="ANTRUN_NOHUP" value="true" />  <!-- optional -->
 #   <env key="ANTRUN_OUTPUT" value="output.log" />  <!-- required, may
be /dev/null -->
 #   <arg value="real executable" />
 # </exec>

 # If ANTRUN_NOHUP environment variable is set to true/yes/nohup, run
the
 # executable prefixed with "nohup" making it immune to logging out.
 case "$ANTRUN_NOHUP" in
    true|yes|nohup) ANTRUN_NOHUP=nohup ;;
    *) unset ANTRUN_NOHUP ;;
 esac

 # ANTRUN_OUTPUT environment variable must be set to output file name or
 # executable can't run detached
ANTRUN_OUTPUT=../my/path/here/nohup.out  ### <-- THE ONLY THING I ADDED
 if [ -n "$ANTRUN_OUTPUT" ]
 then
    $ANTRUN_NOHUP $@ </dev/null > "$ANTRUN_OUTPUT" 2>&1 &
    exit 0
 else
    echo "$0: ERROR: variable ANTRUN_OUTPUT must be set to  output file
name!"
    exit 1
 fi

My ant exec:
<exec executable="ssh">
           <arg line="${remote.host} ./antRunAsync.sh ./run_app.sh " />
</exec>

And run_app.sh is simply:
cd /path/to/my/app
nohup ./run.sh &


I don't actually know if it works with rexec, I had issues getting rexec
to work and went back to exec.


-----Original Message-----
From: Z W [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 28, 2008 3:23 PM
To: Ant Users List
Subject: Re: nohup and Ant question

Barry

It's a little complicated for me in that solution.
Do you have a simpler one ?
Will it work for <rexec> as opposed to <exec> ?

Thanks
<HTML><BODY><P><hr size=1></P><br>
<P><br>
Confidentiality Notice!<br>
This electronic transmission and any attached documents or other<br>
writings are confidential and are for the sole use of the intended<br>
recipient(s) identified above. This message may contain information<br>
that is privileged, confidential or otherwise protected from<br>
disclosure under applicable law. If the receiver of this<br>
information is not the intended recipient, or the employee, or<br>
agent responsible for delivering the information to the intended<br>
recipient, you are hereby notified that any use, reading,<br>
dissemination, distribution, copying or storage of this information<br>
is strictly prohibited. If you have received this information in<br>
error, please notify the sender by return email and delete the<br>
electronic transmission, including all attachments from your<br>
system.<br>
<P></BODY></HTML>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to