On Fri, Jul 10, 2009 at 3:17 AM, Martin Grotzke <
[email protected]> wrote:
> Hi,
>
> I have another one :)
>
> I want to start a mailserver with test.setup so that it's available for
> tests.
>
> I created a task that starts a simple java mail server which blocks
> until it's interrupted. Now I wonder how it's possible to run this in
> the background during the tests.
>
> This is the task:
>
> desc "Start mailserver on unprivileged ports"
> task "run-mailserver" do
> begin
> Java::Commands.java('com.ericdaugherty.mail.server.Mail',
> _('runtime/mailserver'),
> :classpath => ['runtime/mailserver/lib',
> FileList['runtime/mailserver/lib/*.jar']]
> )
> rescue Exception
> # this is excepted, as java probably was interrupted via CTRL-C
> end
> end
>
Generally speaking:
Thread.new do
< start your process >
end
This starts a new thread and returns control to your code (anything
following the end). Meanwhile the thread can start a new process and will
end when the program returns.
The main thread will *not* block so you need some way of telling when the
process is ready to receive requests, and also some way of shutting it down
from at_exit.
Assaf
> Is it possible somehow to run this in the background during the tests? I
> had a look at the jetty stuff, but there the lifecycle is managed via
> URL communication...
>
> Thanx && cheers,
> Martin
>
>
>