From 6378ba0f988de332d2e2c57367efafa9b38b7760 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Tue, 9 Dec 2025 15:42:43 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20feat(LpjServiceProvider):?= =?UTF-8?q?=20Konfigurasi=20scheduling=20otomatis=20untuk=20cleanup=20insp?= =?UTF-8?q?eksi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Menambahkan registrasi commands dan scheduling untuk cleanup data inspeksi dengan konfigurasi multi-server dan logging - Register 3 command cleanup: CleanupInspeksiDataCommand, CleanupSingleInspeksiCommand, dan CleanupInspeksiStatusCommand - Daily cleanup scheduling setiap jam 02:00 dengan opsi --force dan withoutOverlapping() - Weekly backup cleanup setiap minggu pukul 03:00 pada hari minggu - Multi-server support dengan onOneServer() untuk environment clustered - Background execution dengan runInBackground() untuk performa optimal - Dedicated logging ke storage/logs/cleanup-inspeksi.log dan cleanup-inspeksi-weekly.log - Service binding untuk BankDataService dengan dependency injection - Modular structure dengan namespace dan module path yang terorganisir --- app/Providers/LpjServiceProvider.php | 55 +++++++++++++++++++--------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/app/Providers/LpjServiceProvider.php b/app/Providers/LpjServiceProvider.php index a7f8df1..45c145b 100644 --- a/app/Providers/LpjServiceProvider.php +++ b/app/Providers/LpjServiceProvider.php @@ -32,25 +32,46 @@ } /** - * Register commands in the format of Command::class - */ - protected function registerCommands() - : void - { - // $this->commands([]); - } + * Register commands in the format of Command::class + */ + protected function registerCommands() + : void + { + $this->commands([ + \Modules\Lpj\Console\Commands\CleanupInspeksiDataCommand::class, + \Modules\Lpj\Console\Commands\CleanupSingleInspeksiCommand::class, + \Modules\Lpj\Console\Commands\CleanupInspeksiStatusCommand::class, + ]); + } /** - * Register command Schedules. - */ - protected function registerCommandSchedules() - : void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } + * Register command Schedules. + */ + protected function registerCommandSchedules() + : void + { + $this->app->booted(function () { + $schedule = $this->app->make(\Illuminate\Console\Scheduling\Schedule::class); + + // Jalankan cleanup inspeksi setiap hari jam 2 pagi + $schedule->command('lpj:cleanup-inspeksi --force') + ->dailyAt('02:00') + ->withoutOverlapping() + ->onOneServer() + ->runInBackground() + ->appendOutputTo(storage_path('logs/cleanup-inspeksi.log')); + + // Backup cleanup setiap minggu + $schedule->command('lpj:cleanup-inspeksi --force') + ->weekly() + ->sundays() + ->at('03:00') + ->withoutOverlapping() + ->onOneServer() + ->runInBackground() + ->appendOutputTo(storage_path('logs/cleanup-inspeksi-weekly.log')); + }); + } /** * Register translations.