wip
This commit is contained in:
@@ -15,7 +15,7 @@ class ServerController extends Controller
|
||||
{
|
||||
$servers = auth()->user()->servers()->latest()->paginate();
|
||||
|
||||
$providers = auth()->user()->package->providers()->pluck('label', 'id');
|
||||
$providers = auth()->user()->package->providers()->pluck('name', 'id');
|
||||
|
||||
return inertia('Servers/Index', [
|
||||
'servers' => ServerResource::collection($servers),
|
||||
|
||||
@@ -45,5 +45,13 @@ class CreateServer implements ShouldQueue
|
||||
|
||||
$this->server->ploi_id = $ploiServer->id;
|
||||
$this->server->save();
|
||||
|
||||
// Lets fetch the status after 2 minutes
|
||||
dispatch(new FetchServerStatus($this->server))->delay(now()->addMinutes(2));
|
||||
}
|
||||
|
||||
public function failed(\Exception $exception)
|
||||
{
|
||||
$this->server->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Jobs\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Services\Ploi\Ploi;
|
||||
use App\Traits\JobHasThresholds;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -35,6 +36,33 @@ class FetchServerStatus implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
// If we tried over 10 times, game over, delete the site
|
||||
if ($this->hasReachedThresholdLimit(10)) {
|
||||
$this->server->delete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ploi = new Ploi;
|
||||
|
||||
$ploiServer = $ploi->server($this->server->ploi_id)->get()->getData();
|
||||
|
||||
if ($ploiServer->status !== Server::STATUS_ACTIVE) {
|
||||
$this->incrementThreshold();
|
||||
|
||||
dispatch(new self($this->server, $this->threshold))->delay(now()->addMinutes(2));
|
||||
|
||||
// Check if an IP address is present already
|
||||
if ($ploiServer->ip_address && !$this->server->ip) {
|
||||
$this->server->ip = $ploiServer->ip_address;
|
||||
$this->server->save();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->server->status = $ploiServer->status;
|
||||
$this->server->ip = $ploiServer->ip_address;
|
||||
$this->server->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class FetchSiteStatus implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
$ploi = new Ploi(config('services.ploi.token'));
|
||||
$ploi = new Ploi;
|
||||
|
||||
$ploiSite = $ploi->server($this->site->server->ploi_id)->sites()->get($this->site->ploi_id)->getData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user