coolify/app/Jobs/ResourceStatusJob.php

45 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Jobs;
use App\Models\Application;
2023-08-21 18:00:12 +02:00
use App\Models\StandalonePostgresql;
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;
2023-08-16 17:18:50 +02:00
class ResourceStatusJob implements ShouldQueue, ShouldBeUnique
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $applications;
2023-08-21 18:00:12 +02:00
public $postgresqls;
public function __construct()
{
$this->applications = Application::all();
2023-08-21 18:00:12 +02:00
$this->postgresqls = StandalonePostgresql::all();
}
public function handle(): void
{
try {
foreach ($this->applications as $application) {
2023-08-21 18:00:12 +02:00
dispatch(new ApplicationContainerStatusJob(
application: $application,
));
}
foreach ($this->postgresqls as $postgresql) {
dispatch(new DatabaseContainerStatusJob(
database: $postgresql,
));
}
2023-08-24 16:14:09 +02:00
} catch (\Exception $th) {
send_internal_notification('ResourceStatusJob failed with: ' . $th->getMessage());
}
}
}