server fix

This commit is contained in:
2025-03-30 13:14:00 +00:00
parent cf804cff48
commit 40097e81c0

View File

@@ -20,27 +20,28 @@ class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted
protected Server $server, protected Server $server,
protected string $rootPassword, protected string $rootPassword,
protected string $sudoPassword, protected string $sudoPassword,
) ) {
{
// //
} }
public function handle(): void public function handle(): void
{ {
try { $process = Ssh::create('root', $this->server->ipv4 ?? $this->server->ipv6)
Ssh::create('root', $this->server->ipv4 ?? $this->server->ipv6)
->usePassword($this->rootPassword) ->usePassword($this->rootPassword)
->setTimeout(10) ->setTimeout(10)
->execute('echo "Connected"'); ->execute('echo "Connected"');
if (! $process->isSuccessful()) {
logger('server not reachable');
logger($process->getErrorOutput());
throw new \Exception('Server is not reachable');
}
$this->server->update([ $this->server->update([
'status' => ServerStatus::UNPROVISIONED, 'status' => ServerStatus::UNPROVISIONED,
]); ]);
dispatch(new ProvisionServer($this->server, $this->rootPassword, $this->sudoPassword)); dispatch(new ProvisionServer($this->server, $this->rootPassword, $this->sudoPassword));
} catch (\Throwable $e) {
return;
}
} }
public function failed(\Throwable $exception): void public function failed(\Throwable $exception): void