mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
fix realtime update
This commit is contained in:
@ -11,24 +11,31 @@ class ContinueInstallation extends InstallationJob
|
||||
|
||||
protected int $attempts;
|
||||
|
||||
public function __construct(Server $server)
|
||||
public function __construct(Server $server, int $attempts = 0)
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->attempts = 2;
|
||||
$this->attempts = $attempts;
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->attempts >= 2) {
|
||||
$this->server->update([
|
||||
'status' => 'installation_failed',
|
||||
]);
|
||||
event(
|
||||
new Broadcast('install-server-failed', [
|
||||
'server' => $this->server,
|
||||
])
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(new self($this->server, $this->attempts++))->delay(now()->addMinute());
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
use App\Jobs\LongJob;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class InstallationJob implements ShouldQueue, ShouldBeUnique
|
||||
abstract class InstallationJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use LongJob;
|
||||
|
Reference in New Issue
Block a user