Add support for automatically pruning activity logs

This commit is contained in:
DaneEveritt 2022-05-29 19:45:00 -04:00
parent 9b7af02690
commit e15985ea39
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 41 additions and 6 deletions

View file

@ -2,8 +2,13 @@
namespace Pterodactyl\Console;
use Pterodactyl\Models\ActivityLog;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Database\Console\PruneCommand;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Pterodactyl\Console\Commands\Schedule\ProcessRunnableCommand;
use Pterodactyl\Console\Commands\Maintenance\PruneOrphanedBackupsCommand;
use Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
class Kernel extends ConsoleKernel
{
@ -21,14 +26,16 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// Execute scheduled commands for servers every minute, as if there was a normal cron running.
$schedule->command('p:schedule:process')->everyMinute()->withoutOverlapping();
$schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping();
$schedule->command(CleanServiceBackupFilesCommand::class)->daily();
if (config('backups.prune_age')) {
// Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted.
$schedule->command('p:maintenance:prune-backups')->everyThirtyMinutes();
$schedule->command(PruneOrphanedBackupsCommand::class)->everyThirtyMinutes();
}
// Every day cleanup any internal backups of service files.
$schedule->command('p:maintenance:clean-service-backups')->daily();
if (config('activity.prune_days')) {
$schedule->command(PruneCommand::class, ['--model' => [ActivityLog::class]])->daily();
}
}
}