Skip to content
Snippets Groups Projects
Commit c19a2130 authored by Steve Trevanion's avatar Steve Trevanion
Browse files

method to cleanup blast database

parent b06665bd
No related branches found
No related tags found
No related merge requests found
......@@ -1156,4 +1156,41 @@ sub rotate_daily_tables {
}
#----------------------------------------------------------------------
=head2 cleanup_processes
Arg [1] : none
Function : Kills any sleeping processes older that 1000
Returntype: boolean
Exceptions:
Caller :
Example :
=cut
sub cleanup_processes {
my $self = shift;
my $dbh = $self->dbc->db_handle;
my $sth = $self->prepare( 'show processlist' );
my $kill_sth = $self->prepare('kill ?');
$sth->execute;
my $res = $sth->fetchall_arrayref([0,3,4,5]);
my $c = 0;
foreach my $ps (@$res) {
my ($pid,$db,$stat,$time) = @$ps;
if ($db eq 'ensembl_blast') {
if ( ($stat eq 'Sleep') && ($time > 1000) ) {
$kill_sth->execute($pid);
$c++;
}
}
}
warn "Killed $c processes";
return 1;
}
1;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment