mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Add Logger::stop_online_logging().
This commit is contained in:
15
bin/pt-agent
15
bin/pt-agent
@@ -4975,13 +4975,20 @@ sub _log {
|
||||
return;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
sub stop_online_logging {
|
||||
my $self = shift;
|
||||
if ( $self->online_logging ) {
|
||||
if ( $self->_thread && $self->_thread->is_running() ) {
|
||||
my @stop :shared = (undef, undef);
|
||||
$self->_message_queue->enqueue(\@stop); # stop the thread
|
||||
$self->_thread->join();
|
||||
}
|
||||
$self->online_logging(0);
|
||||
return;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
$self->stop_online_logging();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5365,8 +5372,8 @@ sub main {
|
||||
|
||||
$logger->info("pt-agent exit $exit_status, oktorun $oktorun");
|
||||
|
||||
# Cause Logger::DESTORY to be called.
|
||||
$logger = undef;
|
||||
$logger->stop_online_logging();
|
||||
$logger->info('Waiting for logging thread to stop...');
|
||||
|
||||
return $exit_status;
|
||||
}
|
||||
|
@@ -207,13 +207,20 @@ sub _log {
|
||||
return;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
sub stop_online_logging {
|
||||
my $self = shift;
|
||||
if ( $self->online_logging ) {
|
||||
if ( $self->_thread && $self->_thread->is_running() ) {
|
||||
my @stop :shared = (undef, undef);
|
||||
$self->_message_queue->enqueue(\@stop); # stop the thread
|
||||
$self->_thread->join();
|
||||
}
|
||||
$self->online_logging(0);
|
||||
return;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
$self->stop_online_logging();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user