code improvements
This commit is contained in:
36
app/Console/Commands/Init.php
Normal file
36
app/Console/Commands/Init.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\ApplicationDeploymentQueue;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Init extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:init';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Cleanup instance related stuffs';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get();
|
||||
ray($halted_deployments);
|
||||
} catch (\Exception $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class Kernel extends ConsoleKernel
|
||||
} else {
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
$schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
|
||||
$schedule->job(new InstanceProxyCheckJob)->everyFiveMinutes();
|
||||
$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ class ApplicationController extends Controller
|
||||
if (!$application) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
return view('project.application.deployments', ['application' => $application]);
|
||||
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 8);
|
||||
return view('project.application.deployments', ['application' => $application, 'deployments' => $deployments, 'deployments_count' => $count]);
|
||||
}
|
||||
|
||||
public function deployment()
|
||||
|
||||
@@ -7,7 +7,7 @@ use Livewire\Component;
|
||||
|
||||
class Deployments extends Component
|
||||
{
|
||||
public int $application_id;
|
||||
public Application $application;
|
||||
public $deployments = [];
|
||||
public int $deployments_count = 0;
|
||||
public string $current_url;
|
||||
@@ -18,6 +18,17 @@ class Deployments extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->current_url = url()->current();
|
||||
$this->show_more();
|
||||
}
|
||||
private function show_more()
|
||||
{
|
||||
if (count($this->deployments) !== 0) {
|
||||
$this->show_next = true;
|
||||
if (count($this->deployments) < $this->default_take) {
|
||||
$this->show_next = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
public function reload_deployments()
|
||||
{
|
||||
@@ -28,17 +39,11 @@ class Deployments extends Component
|
||||
if ($take) {
|
||||
$this->skip = $this->skip + $take;
|
||||
}
|
||||
|
||||
$take = $this->default_take;
|
||||
['deployments' => $deployments, 'count' => $count] = Application::find($this->application_id)->deployments($this->skip, $take);
|
||||
|
||||
['deployments' => $deployments, 'count' => $count] = $this->application->deployments($this->skip, $take);
|
||||
$this->deployments = $deployments;
|
||||
$this->deployments_count = $count;
|
||||
if (count($this->deployments) !== 0) {
|
||||
$this->show_next = true;
|
||||
if (count($this->deployments) < $take) {
|
||||
$this->show_next = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->show_more();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,6 +309,8 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}
|
||||
$this->application_deployment_queue->update([
|
||||
'status' => $status,
|
||||
]);
|
||||
ray($this->application_deployment_queue)->purple();
|
||||
ray($this->activity)->purple();
|
||||
$this->activity->properties = $this->activity->properties->merge([
|
||||
'status' => $status,
|
||||
]);
|
||||
|
||||
@@ -29,7 +29,7 @@ class InstanceProxyCheckJob implements ShouldQueue
|
||||
{
|
||||
try {
|
||||
$container_name = 'coolify-proxy';
|
||||
$servers = Server::whereRelation('settings', 'is_reachable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();
|
||||
$servers = Server::whereRelation('settings', 'is_usable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();
|
||||
|
||||
foreach ($servers as $server) {
|
||||
$status = get_container_status(server: $server, container_id: $container_name);
|
||||
|
||||
Reference in New Issue
Block a user