From 03b0a62a22ac71c42243bf434cbfd005af2156b5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 19 Dec 2021 01:25:49 -0700 Subject: [PATCH 1/2] Update console kernel, add db session garbage collector that runs twice daily --- .../DatabaseSessionGarbageCollector.php | 56 +++++++++++++++++++ app/Console/Kernel.php | 1 + 2 files changed, 57 insertions(+) create mode 100644 app/Console/Commands/DatabaseSessionGarbageCollector.php diff --git a/app/Console/Commands/DatabaseSessionGarbageCollector.php b/app/Console/Commands/DatabaseSessionGarbageCollector.php new file mode 100644 index 00000000..db11cb80 --- /dev/null +++ b/app/Console/Commands/DatabaseSessionGarbageCollector.php @@ -0,0 +1,56 @@ +whereNull('user_id')->delete(); + }); + + DB::transaction(function() { + $ts = now()->subMonths(3)->timestamp; + DB::table('sessions')->where('last_activity', '<', $ts)->delete(); + }); + + return Command::SUCCESS; + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0dd65888..dd1bae94 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -31,6 +31,7 @@ class Kernel extends ConsoleKernel $schedule->command('story:gc')->everyFiveMinutes(); $schedule->command('gc:failedjobs')->dailyAt(3); $schedule->command('gc:passwordreset')->dailyAt('09:41'); + $schedule->command('gc:sessions')->twiceDaily(13, 23); } /** From fd2d37432bee2cd58166d3726141d068c242ac1e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 19 Dec 2021 01:28:55 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf82550..e76ba688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - Updated ContextMenu component, fix account url paths. ([01ca1edd](https://github.com/pixelfed/pixelfed/commit/01ca1edd)) - Updated PollCard component, add showBorder prop. ([0c8fffbd](https://github.com/pixelfed/pixelfed/commit/0c8fffbd)) - Updated PhotoPresenter component, add lightbox toggle. ([0cc1365f](https://github.com/pixelfed/pixelfed/commit/0cc1365f)) +- Updated console kernel, add db session garbage collector that runs twice daily. ([03b0a62a](https://github.com/pixelfed/pixelfed/commit/03b0a62a)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)