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