code improvements
This commit is contained in:
parent
4daa10d38b
commit
b370826624
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 @@ protected function schedule(Schedule $schedule): void
|
||||
} 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 @@ public function deployments()
|
||||
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 @@
|
||||
|
||||
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 @@ public function load_deployments(int|null $take = null)
|
||||
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 @@ private function next(string $status)
|
||||
$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 @@ public function handle()
|
||||
{
|
||||
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);
|
||||
|
1
docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/type
Normal file
1
docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/type
Normal file
@ -0,0 +1 @@
|
||||
oneshot
|
2
docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up
Normal file
2
docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up
Normal file
@ -0,0 +1,2 @@
|
||||
#!/command/execlineb -P
|
||||
php /var/www/html/artisan app:init
|
@ -1,5 +1,4 @@
|
||||
<div class="flex flex-col gap-2" wire:init='load_deployments'
|
||||
@if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif>
|
||||
<div class="flex flex-col gap-2" @if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif>
|
||||
<h2 class="pt-4">Deployments <span class="text-xs">({{ $deployments_count }})</span></h2>
|
||||
@if ($show_next)
|
||||
<x-forms.button wire:click="load_deployments({{ $default_take }})">Show More
|
||||
|
@ -1,5 +1,5 @@
|
||||
<x-layout>
|
||||
<h1>Deployments</h1>
|
||||
<livewire:application.heading :application="$application" />
|
||||
<livewire:project.application.deployments :application_id="$application->id" />
|
||||
<livewire:project.application.deployments :application="$application" :deployments="$deployments" :deployments_count="$deployments_count" />
|
||||
</x-layout>
|
||||
|
Loading…
Reference in New Issue
Block a user