24 |
sub _fork { |
sub _fork { |
25 |
my ($self,$filename) = @_; |
my ($self,$filename) = @_; |
26 |
$ENV{FREY_PORT} = int( 16000 + rand(1000) ); |
$ENV{FREY_PORT} = int( 16000 + rand(1000) ); |
27 |
$filename ||= './bin/server.pl'; |
$filename ||= './bin/continuity-server.pl'; |
28 |
$kid_pid = open($kid_out, '-|'); |
$kid_pid = open($kid_out, '-|'); |
29 |
die "Unable to fork!" unless defined($kid_pid); |
die "Unable to fork!" unless defined($kid_pid); |
30 |
if($kid_pid) { |
if($kid_pid) { |
46 |
$self->_fork unless $kid_out; |
$self->_fork unless $kid_out; |
47 |
my $host = '127.0.0.1:' . $ENV{FREY_PORT}; |
my $host = '127.0.0.1:' . $ENV{FREY_PORT}; |
48 |
warn "## waiting for $host to start"; |
warn "## waiting for $host to start"; |
49 |
while ( ! IO::Socket::INET->new( $host ) ) { |
if ( ! IO::Socket::INET->new( $host ) ) { |
50 |
warn "."; |
die "can't start server on $host"; |
|
sleep 1; |
|
51 |
} |
} |
52 |
return "http://$host"; |
return "http://$host"; |
53 |
} |
} |