An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
reduce: minimize logging in cleanup commands
Andras Bacsaic25272de8d4f
diff --git a/app/Console/Commands/CleanupNames.php b/app/Console/Commands/CleanupNames.phpindex 2992e32b99..e4bbe4a122 100644--- a/app/Console/Commands/CleanupNames.php+++ b/app/Console/Commands/CleanupNames.php@@ -63,8 +63,6 @@ class CleanupNames extends Commandpublic function handle(): int{- $this->info('π Scanning for invalid characters in name fields...');-if ($this->option('backup') && ! $this->option('dry-run')) {$this->createBackup();}@@ -75,7 +73,7 @@ class CleanupNames extends Command: $this->modelsToClean;if ($modelFilter && ! isset($this->modelsToClean[$modelFilter])) {- $this->error("β Unknown model: {$modelFilter}");+ $this->error("Unknown model: {$modelFilter}");$this->info('Available models: '.implode(', ', array_keys($this->modelsToClean)));return self::FAILURE;@@ -88,19 +86,21 @@ class CleanupNames extends Command$this->processModel($modelName, $modelClass);}- $this->displaySummary();-if (! $this->option('dry-run') && $this->totalCleaned > 0) {$this->logChanges();}+ if ($this->option('dry-run')) {+ $this->info("Name cleanup: would sanitize {$this->totalCleaned} records");+ } else {+ $this->info("Name cleanup: sanitized {$this->totalCleaned} records");+ }+return self::SUCCESS;}protected function processModel(string $modelName, string $modelClass): void{- $this->info("\nπ Processing {$modelName}...");-try {$records = $modelClass::all(['id', 'name']);$cleaned = 0;@@ -128,21 +128,17 @@ class CleanupNames extends Command$cleaned++;$this->totalCleaned++;- $this->warn(" π§Ή {$modelName} #{$record->id}:");- $this->line(' From: '.$this->truncate($originalName, 80));- $this->line(' To: '.$this->truncate($sanitizedName, 80));+ // Only log in dry-run mode to preview changes+ if ($this->option('dry-run')) {+ $this->warn(" π§Ή {$modelName} #{$record->id}:");+ $this->line(' From: '.$this->truncate($originalName, 80));+ $this->line(' To: '.$this->truncate($sanitizedName, 80));+ }}}- if ($cleaned > 0) {- $action = $this->option('dry-run') ? 'would be sanitized' : 'sanitized';- $this->info(" β {$cleaned}/{$records->count()} records {$action}");- } else {- $this->info(' β¨ No invalid characters found');- }-} catch (\Exception $e) {- $this->error(" β Error processing {$modelName}: ".$e->getMessage());+ $this->error("Error processing {$modelName}: ".$e->getMessage());}}@@ -165,28 +161,6 @@ class CleanupNames extends Commandreturn $sanitized;}- protected function displaySummary(): void- {- $this->info("\n".str_repeat('=', 60));- $this->info('π CLEANUP SUMMARY');- $this->info(str_repeat('=', 60));-- $this->line("Records processed: {$this->totalProcessed}");- $this->line("Records with invalid characters: {$this->totalCleaned}");-- if ($this->option('dry-run')) {- $this->warn("\nπ DRY RUN - No changes were made to the database");- $this->info('Run without --dry-run to apply these changes');- } else {- if ($this->totalCleaned > 0) {- $this->info("\nβ Database successfully sanitized!");- $this->info('Changes logged to storage/logs/name-cleanup.log');- } else {- $this->info("\nβ¨ No cleanup needed - all names are valid!");- }- }- }-protected function logChanges(): void{$logFile = storage_path('logs/name-cleanup.log');@@ -208,8 +182,6 @@ class CleanupNames extends Commandprotected function createBackup(): void{- $this->info('πΎ Creating database backup...');-try {$backupFile = storage_path('backups/name-cleanup-backup-'.now()->format('Y-m-d-H-i-s').'.sql');@@ -229,15 +201,8 @@ class CleanupNames extends Command);exec($command, $output, $returnCode);-- if ($returnCode === 0) {- $this->info("β Backup created: {$backupFile}");- } else {- $this->warn('β οΈ Backup creation may have failed. Proceeding anyway...');- }} catch (\Exception $e) {- $this->warn('β οΈ Could not create backup: '.$e->getMessage());- $this->warn('Proceeding without backup...');+ // Silently continue}}diff --git a/app/Console/Commands/CleanupRedis.php b/app/Console/Commands/CleanupRedis.phpindex abf8010c06..199e168fc9 100644--- a/app/Console/Commands/CleanupRedis.php+++ b/app/Console/Commands/CleanupRedis.php@@ -18,10 +18,6 @@ class CleanupRedis extends Command$dryRun = $this->option('dry-run');$skipOverlapping = $this->option('skip-overlapping');- if ($dryRun) {- $this->info('DRY RUN MODE - No data will be deleted');- }-$deletedCount = 0;$totalKeys = 0;@@ -29,8 +25,6 @@ class CleanupRedis extends Command$keys = $redis->keys('*');$totalKeys = count($keys);- $this->info("Scanning {$totalKeys} keys for cleanup...");-foreach ($keys as $key) {$keyWithoutPrefix = str_replace($prefix, '', $key);$type = $redis->command('type', [$keyWithoutPrefix]);@@ -51,14 +45,12 @@ class CleanupRedis extends Command// Clean up overlapping queues if not skippedif (! $skipOverlapping) {- $this->info('Cleaning up overlapping queues...');$overlappingCleaned = $this->cleanupOverlappingQueues($redis, $prefix, $dryRun);$deletedCount += $overlappingCleaned;}// Clean up stale cache locks (WithoutOverlapping middleware)if ($this->option('clear-locks')) {- $this->info('Cleaning up stale cache locks...');$locksCleaned = $this->cleanupCacheLocks($dryRun);$deletedCount += $locksCleaned;}@@ -66,15 +58,14 @@ class CleanupRedis extends Command// Clean up stuck jobs (restart mode = aggressive, runtime mode = conservative)$isRestart = $this->option('restart');if ($isRestart || $this->option('clear-locks')) {- $this->info($isRestart ? 'Cleaning up stuck jobs (RESTART MODE - aggressive)...' : 'Checking for stuck jobs (runtime mode - conservative)...');$jobsCleaned = $this->cleanupStuckJobs($redis, $prefix, $dryRun, $isRestart);$deletedCount += $jobsCleaned;}if ($dryRun) {- $this->info("DRY RUN: Would delete {$deletedCount} out of {$totalKeys} keys");+ $this->info("Redis cleanup: would delete {$deletedCount} items");} else {- $this->info("Deleted {$deletedCount} out of {$totalKeys} keys");+ $this->info("Redis cleanup: deleted {$deletedCount} items");}}@@ -85,11 +76,8 @@ class CleanupRedis extends Command// Delete completed and failed jobsif (in_array($status, ['completed', 'failed'])) {- if ($dryRun) {- $this->line("Would delete job: {$keyWithoutPrefix} (status: {$status})");- } else {+ if (! $dryRun) {$redis->command('del', [$keyWithoutPrefix]);- $this->line("Deleted job: {$keyWithoutPrefix} (status: {$status})");}return true;@@ -115,11 +103,8 @@ class CleanupRedis extends Commandforeach ($patterns as $pattern => $description) {if (str_contains($keyWithoutPrefix, $pattern)) {- if ($dryRun) {- $this->line("Would delete {$description}: {$keyWithoutPrefix}");- } else {+ if (! $dryRun) {$redis->command('del', [$keyWithoutPrefix]);- $this->line("Deleted {$description}: {$keyWithoutPrefix}");}return true;@@ -132,11 +117,8 @@ class CleanupRedis extends Command$weekAgo = now()->subDays(7)->timestamp;if ($timestamp < $weekAgo) {- if ($dryRun) {- $this->line("Would delete old timestamped data: {$keyWithoutPrefix}");- } else {+ if (! $dryRun) {$redis->command('del', [$keyWithoutPrefix]);- $this->line("Deleted old timestamped data: {$keyWithoutPrefix}");}return true;@@ -160,8 +142,6 @@ class CleanupRedis extends Command}}- $this->info('Found '.count($queueKeys).' queue-related keys');-// Group queues by name pattern to find duplicates$queueGroups = [];foreach ($queueKeys as $queueKey) {@@ -193,7 +173,6 @@ class CleanupRedis extends Commandprivate function deduplicateQueueGroup($redis, $baseName, $keys, $dryRun){$cleanedCount = 0;- $this->line("Processing queue group: {$baseName} (".count($keys).' keys)');// Sort keys to keep the most recent oneusort($keys, function ($a, $b) {@@ -244,11 +223,8 @@ class CleanupRedis extends Command}if ($shouldDelete) {- if ($dryRun) {- $this->line(" Would delete empty queue: {$redundantKey}");- } else {+ if (! $dryRun) {$redis->command('del', [$redundantKey]);- $this->line(" Deleted empty queue: {$redundantKey}");}$cleanedCount++;}@@ -271,15 +247,12 @@ class CleanupRedis extends Commandif (count($uniqueItems) < count($items)) {$duplicates = count($items) - count($uniqueItems);- if ($dryRun) {- $this->line(" Would remove {$duplicates} duplicate jobs from queue: {$queueKey}");- } else {+ if (! $dryRun) {// Rebuild the list with unique items$redis->command('del', [$queueKey]);foreach (array_reverse($uniqueItems) as $item) {$redis->command('lpush', [$queueKey, $item]);}- $this->line(" Removed {$duplicates} duplicate jobs from queue: {$queueKey}");}$cleanedCount += $duplicates;}@@ -307,13 +280,9 @@ class CleanupRedis extends Command}}if (empty($lockKeys)) {- $this->info(' No cache locks found.');-return 0;}- $this->info(' Found '.count($lockKeys).' cache lock(s)');-foreach ($lockKeys as $lockKey) {// Check TTL to identify stale locks$ttl = $redis->ttl($lockKey);@@ -326,18 +295,11 @@ class CleanupRedis extends Command$this->warn(" Would delete STALE lock (no expiration): {$lockKey}");} else {$redis->del($lockKey);- $this->info(" β Deleted STALE lock: {$lockKey}");}$cleanedCount++;- } elseif ($ttl > 0) {- $this->line(" Skipping active lock (expires in {$ttl}s): {$lockKey}");}}- if ($cleanedCount === 0) {- $this->info(' No stale locks found (all locks have expiration set)');- }-return $cleanedCount;}@@ -453,17 +415,11 @@ class CleanupRedis extends Command$redis->command('hset', [$keyWithoutPrefix, 'status', 'failed']);$redis->command('hset', [$keyWithoutPrefix, 'failed_at', $now]);$redis->command('hset', [$keyWithoutPrefix, 'exception', "Job cleaned up by cleanup:redis - {$reason}"]);-- $this->info(" β Marked as FAILED: {$jobClass} (processing for ".round($processingTime / 60, 1).' min) - '.$reason);}$cleanedCount++;}}- if ($cleanedCount === 0) {- $this->info($isRestart ? ' No jobs to clean up' : ' No stuck jobs found (all jobs running normally)');- }-return $cleanedCount;}}