mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 19:01:37 +00:00
25 lines
514 B
PHP
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;
|
|
}
|
|
}
|