DR-Tarantool
view release on metacpan or search on metacpan
lib/DR/Tarantool/StartTest.pm view on Meta::CPAN
$signame ||= 'TERM';
if ($self->{child}) {
kill $signame => $self->{child};
waitpid $self->{child}, 0;
delete $self->{child};
}
$self->{started} = 0;
}
=head2 is_dead
Return true if child Tarantool process is dead.
=cut
sub is_dead {
my ($self) = @_;
return 1 unless $self->{child};
return 0 if 0 < kill 0 => $self->{child};
return 1;
}
=head2 DESTROY
Destructor. Kills tarantool, removes temporary files.
=cut
sub DESTROY {
my ($self) = @_;
local $?;
chdir $self->{cwd};
return unless $self->{master} == $$;
if (-r $self->{core}) {
warn "Tarantool was coredumped\n" if -r $self->{core};
system "echo bt|gdb $self->{box} $self->{core}";
}
$self->kill;
rmtree $self->{temp} if $self->{temp} and !$self->{dont_unlink_temp};
}
sub temp_dir {
my ($self) = @_;
return $self->{temp};
}
sub clean_xlogs {
my ($self) = @_;
return unless $self->{temp};
my @xlogs = glob catfile $self->{temp}, '*.xlog';
unlink for @xlogs;
}
{
my %busy_ports;
sub _find_free_port {
while( 1 ) {
my $port = 10000 + int rand 30000;
next if exists $busy_ports{ $port };
next unless IO::Socket::INET->new(
Listen => 5,
LocalAddr => '127.0.0.1',
LocalPort => $port,
Proto => 'tcp',
(($^O eq 'MSWin32') ? () : (ReuseAddr => 1)),
);
return $busy_ports{ $port } = $port;
}
}
}
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
This program is free software, you can redistribute it and/or
modify it under the terms of the Artistic License.
=head1 VCS
The project is placed git repo on github:
L<https://github.com/dr-co/dr-tarantool/>.
=cut
1;
( run in 2.132 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )