initial commit
This commit is contained in:
32
app/Console/Commands/RebuildTraefikRoutesCommand.php
Normal file
32
app/Console/Commands/RebuildTraefikRoutesCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Services\Hosting\Traefik\TraefikGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RebuildTraefikRoutesCommand extends Command
|
||||
{
|
||||
protected $signature = 'hosting:traefik-rebuild {--reload : Reload Traefik after rebuild}';
|
||||
|
||||
protected $description = 'Rebuild all customer Traefik routes from database';
|
||||
|
||||
public function handle(TraefikGenerator $traefik): int
|
||||
{
|
||||
$customers = Customer::query()
|
||||
->where('status', 'active')
|
||||
->whereNotNull('ip_address')
|
||||
->get();
|
||||
|
||||
$traefik->rebuildAllRoutes($customers);
|
||||
|
||||
if ($this->option('reload')) {
|
||||
$traefik->reload();
|
||||
}
|
||||
|
||||
$this->info("Rebuilt routes for {$customers->count()} active customers.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user