mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 22:43:18 +00:00
Merge pull request #3054 from pixelfed/staging
Update console kernel, add db session garbage collector that runs twi…
This commit is contained in:
commit
8d002415e7
3 changed files with 58 additions and 0 deletions
|
@ -54,6 +54,7 @@
|
||||||
- Updated ContextMenu component, fix account url paths. ([01ca1edd](https://github.com/pixelfed/pixelfed/commit/01ca1edd))
|
- 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 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 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/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)
|
## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)
|
||||||
|
|
56
app/Console/Commands/DatabaseSessionGarbageCollector.php
Normal file
56
app/Console/Commands/DatabaseSessionGarbageCollector.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DatabaseSessionGarbageCollector extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'gc:sessions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Database sessions garbage collector';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if(config('session.driver') !== 'database') {
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function() {
|
||||||
|
DB::table('sessions')->whereNull('user_id')->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::transaction(function() {
|
||||||
|
$ts = now()->subMonths(3)->timestamp;
|
||||||
|
DB::table('sessions')->where('last_activity', '<', $ts)->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ class Kernel extends ConsoleKernel
|
||||||
$schedule->command('story:gc')->everyFiveMinutes();
|
$schedule->command('story:gc')->everyFiveMinutes();
|
||||||
$schedule->command('gc:failedjobs')->dailyAt(3);
|
$schedule->command('gc:failedjobs')->dailyAt(3);
|
||||||
$schedule->command('gc:passwordreset')->dailyAt('09:41');
|
$schedule->command('gc:passwordreset')->dailyAt('09:41');
|
||||||
|
$schedule->command('gc:sessions')->twiceDaily(13, 23);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue