Restart After Upgrade
This commit is contained in:
parent
5f006ce042
commit
69d9fe5fb0
2 changed files with 18 additions and 0 deletions
|
@ -33,6 +33,14 @@ class Pterodactyl
|
|||
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
||||
}
|
||||
|
||||
public static function clientadmin()
|
||||
{
|
||||
return Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN"),
|
||||
'Content-type' => 'application/json',
|
||||
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
||||
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
||||
}
|
||||
/**
|
||||
* @return Exception
|
||||
*/
|
||||
|
@ -317,4 +325,11 @@ class Pterodactyl
|
|||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public static function powerAction(Server $server, $action)
|
||||
{
|
||||
return self::clientadmin()->post("/client/servers/{$server->identifier}/power", [
|
||||
"signal" => $action
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -289,6 +289,9 @@ class ServerController extends Controller
|
|||
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
||||
//update user balance
|
||||
$user->decrement('credits', $priceupgrade);
|
||||
//restart the server
|
||||
$response = Pterodactyl::powerAction($server, "restart");
|
||||
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
||||
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue