mirror of
https://github.com/ershisan99/coolify.git
synced 2026-02-03 05:12:05 +00:00
lots of updates + refactoring
This commit is contained in:
@@ -13,17 +13,17 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
class ContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public string $container_name;
|
||||
public string|null $pull_request_id;
|
||||
public Application $application;
|
||||
public $resource;
|
||||
|
||||
public function __construct($application, string $container_name, string|null $pull_request_id = null)
|
||||
public function __construct($resource, string $container_name, string|null $pull_request_id = null)
|
||||
{
|
||||
$this->application = $application;
|
||||
$this->resource = $resource;
|
||||
$this->container_name = $container_name;
|
||||
$this->pull_request_id = $pull_request_id;
|
||||
}
|
||||
@@ -34,21 +34,21 @@ class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
$status = get_container_status(server: $this->application->destination->server, container_id: $this->container_name, throwError: false);
|
||||
if ($this->application->status === 'running' && $status === 'stopped') {
|
||||
$this->application->environment->project->team->notify(new StatusChanged($this->application));
|
||||
$status = get_container_status(server: $this->resource->destination->server, container_id: $this->container_name, throwError: false);
|
||||
if ($this->resource->status === 'running' && $status === 'stopped') {
|
||||
$this->resource->environment->project->team->notify(new StatusChanged($this->resource));
|
||||
}
|
||||
|
||||
if ($this->pull_request_id) {
|
||||
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
|
||||
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->resource->id, $this->pull_request_id);
|
||||
$preview->status = $status;
|
||||
$preview->save();
|
||||
} else {
|
||||
$this->application->status = $status;
|
||||
$this->application->save();
|
||||
$this->resource->status = $status;
|
||||
$this->resource->save();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
ray($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ class InstanceApplicationsStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
try {
|
||||
foreach ($this->applications as $application) {
|
||||
dispatch(new ApplicationContainerStatusJob(
|
||||
application: $application,
|
||||
dispatch(new ContainerStatusJob(
|
||||
resource: $application,
|
||||
container_name: generate_container_name($application->uuid),
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user