Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Start server for test ?
- Kaare Rasmussen
May 17, 2005, 1:49 pm
rate this thread
I've written some tests for my shining new server - so 'Build test' has
something to do.
Yes, I use Module::Build and Test::more.
Problem is, how do I start the server as a daemon and kill it when the
client tests are run?
In production I'd just run it with
perl -MBusiness::Bof::Server::CLI -e run -- -c t/bof.xml &
and kill it when it hs lived long enough. But this doesn't work in a Build
Any ideas to daemonize the server with the test in Module::Build (and store
the pid somewhere so I can kill it again)?
Re: Start server for test ?
I'm using ExtUtils::ModuleMaker and Test::More (note spelling).
I don't see what the question has to do with Module::Build and Test::More.
If you need to run a process in the background, the most basic method
is to fork and exec it:
my $cmd = 'echo starting; sleep 10; echo done';
defined( my $pid = fork) or die "fork: $!";
exec $cmd unless $pid; # the kid does this
# parent again (kid doesn't reach this)
kill 'INT', $pid;
If you run this, you'll note that the background process is killed
before it can print "done". Change "sleep 10" to "sleep 2" in $cmd
and it runs to completion.
Now set $cmd = 'perl -MBusiness::Bof::Server::CLI -e run -- -c t/bof.xml'
and you got what you want.
See "perldoc -f fork" and "perldoc -f exec" for details and
"perldoc perlipc" for variants and alternatives.
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum