2023-04-28 07:00:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2023-05-25 12:23:49 +00:00
|
|
|
class InstanceDockerCleanupJob implements ShouldQueue
|
2023-04-28 07:00:47 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
2023-05-23 13:48:05 +00:00
|
|
|
public $timeout = 500;
|
2023-04-28 07:00:47 +00:00
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*/
|
|
|
|
public function handle(): void
|
|
|
|
{
|
2023-04-28 08:38:22 +00:00
|
|
|
try {
|
|
|
|
$servers = Server::all();
|
|
|
|
foreach ($servers as $server) {
|
2023-05-24 13:25:08 +00:00
|
|
|
instant_remote_process(['docker image prune -f'], $server);
|
2023-04-28 08:38:22 +00:00
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Log::error($e->getMessage());
|
2023-04-28 07:00:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|