mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
init
This commit is contained in:
34
app/Jobs/Installation/ContinueInstallation.php
Normal file
34
app/Jobs/Installation/ContinueInstallation.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Installation;
|
||||
|
||||
use App\Events\Broadcast;
|
||||
use App\Models\Server;
|
||||
|
||||
class ContinueInstallation extends InstallationJob
|
||||
{
|
||||
protected Server $server;
|
||||
|
||||
protected int $attempts;
|
||||
|
||||
public function __construct(Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->attempts = 2;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if ($this->server->provider()->isRunning()) {
|
||||
$this->server->install();
|
||||
} else {
|
||||
$this->attempts--;
|
||||
if ($this->attempts > 0) {
|
||||
sleep(120);
|
||||
$this->handle();
|
||||
} else {
|
||||
event(new Broadcast('install-server-failed', $this->server->toArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user