2023-07-26 14:46:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\Application;
|
2023-08-21 18:00:12 +02:00
|
|
|
use App\Models\StandalonePostgresql;
|
2023-07-26 14:46:28 +02:00
|
|
|
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
|
2023-07-26 14:46:28 +02:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public $applications;
|
2023-08-21 18:00:12 +02:00
|
|
|
public $postgresqls;
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-07-26 14:46:28 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->applications = Application::all();
|
2023-08-21 18:00:12 +02:00
|
|
|
$this->postgresqls = StandalonePostgresql::all();
|
2023-07-26 14:46:28 +02:00
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-07-26 14:46:28 +02:00
|
|
|
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-07-26 14:46:28 +02:00
|
|
|
));
|
|
|
|
}
|
2023-08-24 16:14:09 +02:00
|
|
|
} catch (\Exception $th) {
|
|
|
|
send_internal_notification('ResourceStatusJob failed with: ' . $th->getMessage());
|
2023-08-24 21:09:58 +02:00
|
|
|
ray($th);
|
|
|
|
throw $th;
|
2023-07-26 14:46:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|