diff --git a/Makefile b/Makefile index 6cb6c38b..1c64c466 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ setup_system_user: setup_system_db: sudo -u postgres createuser mirrorcache sudo -u postgres createdb mirrorcache + sudo -u postgres psql -c 'GRANT all ON SCHEMA public TO mirrorcache' mirrorcache setup_production_assets: cd "${DESTDIR}"/usr/share/mirrorcache/ && \ diff --git a/lib/MirrorCache/WebAPI/Command/backstage/run.pm b/lib/MirrorCache/WebAPI/Command/backstage/run.pm index 1585d9a9..b7165104 100644 --- a/lib/MirrorCache/WebAPI/Command/backstage/run.pm +++ b/lib/MirrorCache/WebAPI/Command/backstage/run.pm @@ -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->minion->backend->mysql->close_idle_connections() unless $j->app->schema->pg; + $j->app->schema->disconnect_db; + } + ); + } + ); + } + ); $self->SUPER::run(@args); }