Skip to content

Commit

Permalink
backstage: properly close DB connections in minion jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-suse committed Nov 27, 2024
1 parent d32172e commit 48a27f0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/MirrorCache/WebAPI/Command/backstage/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ sub run {
$self->app->log->info('Resetting all leftover locks after restart');
$minion->reset({locks => 1});
}
$minion->on(
worker => sub () {
my (undef, $worker) = @_;
$worker->on(
dequeue => sub () {
my (undef, $job) = @_;
$job->on(
cleanup => sub () {
my ($j) = @_;
$j->app->schema->disconnect_db;
$j->app->minion->backend->mysql->close_idle_connections() unless $j->app->schema->pg;
}
);
}
);
}
);
$self->SUPER::run(@args);
}

Expand Down

0 comments on commit 48a27f0

Please sign in to comment.