fix: create initial files async
This commit is contained in:
parent
379733938c
commit
965625ad01
26
app/Jobs/ServerFilesFromServerJob.php
Normal file
26
app/Jobs/ServerFilesFromServerJob.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\ServiceApplication;
|
||||||
|
use App\Models\ServiceDatabase;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ServerFilesFromServerJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(public ServiceApplication|ServiceDatabase $service)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->service->getFilesFromServer(isInit: true);
|
||||||
|
}
|
||||||
|
}
|
26
app/Jobs/ServerStorageSaveJob.php
Normal file
26
app/Jobs/ServerStorageSaveJob.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\LocalFileVolume;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ServerStorageSaveJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(public LocalFileVolume $localFileVolume)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->localFileVolume->saveStorageOnServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,7 +13,7 @@ protected static function booted()
|
|||||||
{
|
{
|
||||||
static::created(function (LocalFileVolume $fileVolume) {
|
static::created(function (LocalFileVolume $fileVolume) {
|
||||||
$fileVolume->load(['service']);
|
$fileVolume->load(['service']);
|
||||||
$fileVolume->saveStorageOnServer();
|
dispatch(new \App\Jobs\ServerStorageSaveJob($fileVolume));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public function service()
|
public function service()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Jobs\ServerFilesFromServerJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use App\Models\EnvironmentVariable;
|
use App\Models\EnvironmentVariable;
|
||||||
@ -867,7 +868,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$savedService->getFilesFromServer(isInit: true);
|
dispatch(new ServerFilesFromServerJob($savedService));
|
||||||
return $volume;
|
return $volume;
|
||||||
});
|
});
|
||||||
data_set($service, 'volumes', $serviceVolumes->toArray());
|
data_set($service, 'volumes', $serviceVolumes->toArray());
|
||||||
|
Loading…
Reference in New Issue
Block a user