Files
ladill-hosting/app/Console/Commands/EnsureDomainZoneCommand.php
isaaccladandCursor 40d3dc0fbe
Deploy Ladill Hosting / deploy (push) Successful in 40s
Provision PowerDNS zones immediately on domain link and add ensure-zone command.
Async-only zone jobs left Ladill NS returning REFUSED for new domains, which surfaces as Let's Encrypt SERVFAIL during SSL issuance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 16:56:28 +00:00

59 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\ProvisionDomainSlaveZoneJob;
use App\Jobs\ProvisionDomainZoneJob;
use App\Models\Domain;
use App\Services\Dns\PowerDnsClient;
use Illuminate\Console\Command;
class EnsureDomainZoneCommand extends Command
{
protected $signature = 'domain:ensure-zone
{host : Apex domain host, e.g. amenscientifichospital.com}
{--sync : Run in-process instead of queueing}';
protected $description = 'Create or refresh the PowerDNS zone for a domain (fixes SERVFAIL/REFUSED on Ladill NS).';
public function handle(PowerDnsClient $pdns): int
{
$host = strtolower(trim((string) $this->argument('host'), ". \t\n\r\0\x0B"));
$domain = Domain::query()->where('host', $host)->first();
if (! $domain) {
$this->error("No Domain row found for {$host}. Link the domain in Hosting first.");
return self::FAILURE;
}
$this->info(sprintf(
'Ensuring zone for %s (domain_id=%d, dns_mode=%s, onboarding=%s)',
$domain->host,
$domain->id,
$domain->dns_mode ?: '(null)',
$domain->onboarding_mode ?: '(null)'
));
if (! $this->option('sync')) {
ProvisionDomainZoneJob::dispatch($domain->id);
$this->info('Queued ProvisionDomainZoneJob. Use --sync to run immediately.');
return self::SUCCESS;
}
try {
(new ProvisionDomainZoneJob($domain->id))->handle($pdns);
$this->info('Zone provisioned on PowerDNS master.');
ProvisionDomainSlaveZoneJob::dispatch($domain->id);
$this->info('Queued slave zone sync.');
} catch (\Throwable $e) {
$this->error('Failed: '.$e->getMessage());
return self::FAILURE;
}
return self::SUCCESS;
}
}