vito/app/Actions/Server/RebootServer.php
Saeed Vaziry b2083fc6b2
Migrate to HTMX (#114)
Dropped Livewire
Added HTMX
Added Blade code lint
Drop Mysql and Redis
Migrate to SQLite
2024-03-06 17:02:59 +01:00

25 lines
514 B
PHP

<?php
namespace App\Actions\Server;
use App\Enums\ServerStatus;
use App\Models\Server;
use App\SSHCommands\System\RebootCommand;
use Throwable;
class RebootServer
{
public function reboot(Server $server): Server
{
try {
$server->ssh()->exec(new RebootCommand(), 'reboot');
$server->status = ServerStatus::DISCONNECTED;
$server->save();
} catch (Throwable) {
$server = $server->checkConnection();
}
return $server;
}
}