diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf82550a..e76ba6888 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) diff --git a/app/Console/Commands/DatabaseSessionGarbageCollector.php b/app/Console/Commands/DatabaseSessionGarbageCollector.php new file mode 100644 index 000000000..db11cb80d --- /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 0dd65888a..dd1bae944 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); } /**