[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ant-user
Subject:    Re: What to do if <exec>ed program hangs?
From:       "Hal Hildebrand \(web\)" <Hal.Hildebrand () hellblazer ! com>
Date:       2002-06-30 2:39:23
[Download RAW message or body]

Attached are two patched files to Ant 1.5 beta 2.  With these fixes you
can do:


    <target name="testy" >
        <parallel>
            <sequential>
                ...  Do your testing here ...
                <property name="short_regress_done" value="yes" />
            </sequential>
            <sequential>
                <waitfor maxwait="10}"
                         maxwaitunit="minute"
                         checkevery="1"
                         checkeveryunit="minute">
                    <isset property="test_done" />
                </waitfor>
                <fail unless="test_done" message="Test timed out!" />
            </sequential>
        </parallel>
    </target>

The patched Parallel task's semantics are changed.  If any one of the
parallel threads of the task throws an exception, all the threads are
interrupted.  This means that if you do

<parallel>
    <sequential>
            ... start your server ...
    </sequential>
    <sequential>
            ... wait for server to come up ...
            ... do your tests ...
            ... shutdown the server ...
    </sequential>
</parallel>

and an exception occurs (such as a build exception) in the second
sequential task, the parallel task will exit after interrupting the
first thread.

This is where the second patched file, Execute comes in.  The patch here
is to handle the InterruptedException correctly (or at least handle it)
by always ensuring that the process is destroyed.

Thus if a build exception occurs, the first task (which spawns the
application server process) is interrupted and the process is killed.
Combined with the use of a timeout using the waitfor task, it's a leash
to yank back those pesky processes and make 'em heel.

Combined with the try-finally task from the source forge ant contrib,
you pretty much have all the elements to manage multiple processes in
Ant.

----- Original Message -----
From: "Alexey Solofnenko" <A.Solofnenko@mdl.com>

> Hello,
>
>   we are performing unit testing of our RMI servers during build
process on
> Windows. The tests are started from ANT, but execute in a different
> environment. Unfortunately the servers not always stop correctly and
the
> build hangs. What would be a good way to kill the processes, so ANT
build
> will continue?
>
> - Alexey.
>
> --
> To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>
>
>
>

["Parallel.java" (application/octet-stream)]
["Execute.java" (application/octet-stream)]

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic