Browse Source

fix server upgrade while installation

1day2die 2 years ago
parent
commit
680ffefb1e
1 changed files with 3 additions and 3 deletions
  1. 3 3
      app/Http/Controllers/ServerController.php

+ 3 - 3
app/Http/Controllers/ServerController.php

@@ -389,6 +389,9 @@ class ServerController extends Controller
             $server->allocation = $serverAttributes['allocation'];
             $response = $this->pterodactyl->updateServer($server, $newProduct);
             if ($response->failed()) return redirect()->route('servers.index')->with('error', __("The system was unable to update your server product. Please try again later or contact support."));
+            //restart the server
+            $response = $this->pterodactyl->powerAction($server, 'restart');
+            if ($response->failed()) return redirect()->route('servers.index')->with('error', 'Upgrade Failed! Could not restart the server:   ' . $response->json()['errors'][0]['detail']);
 
             // Remove the allocation property from the server object as it is not a column in the database
             unset($server->allocation);
@@ -406,9 +409,6 @@ class ServerController extends Controller
             // Withdraw the credits for the new product
             $user->decrement('credits', $newProduct->price);
 
-            //restart the server
-            $response = $this->pterodactyl->powerAction($server, 'restart');
-            if ($response->failed()) return redirect()->route('servers.index')->with('error', 'Server upgraded successfully! Could not restart the server:   ' . $response->json()['errors'][0]['detail']);
             return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
         } else {
             return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));