refactor: Update Traefik labels on init and cleanup unnecessary dynamic proxy configuration

This commit is contained in:
Andras Bacsai
2024-08-08 11:15:33 +02:00
parent d3b3c2f7fd
commit 777bff6553

View File

@@ -99,13 +99,18 @@ class Init extends Command
private function update_traefik_labels()
{
try {
Server::where('proxy->type', 'TRAEFIK_V2')->update(['proxy->type' => 'TRAEFIK']);
} catch (\Throwable $e) {
echo "Error in updating traefik labels: {$e->getMessage()}\n";
}
}
private function cleanup_unnecessary_dynamic_proxy_configuration()
{
if (isCloud()) {
foreach ($this->servers as $server) {
try {
if (! $server->isFunctional()) {
continue;
}
@@ -117,6 +122,9 @@ class Init extends Command
return instant_remote_process([
"rm -f $file",
], $server, false);
} catch (\Throwable $e) {
echo "Error in cleaning up unnecessary dynamic proxy configuration: {$e->getMessage()}\n";
}
}
}
@@ -124,7 +132,6 @@ class Init extends Command
private function cleanup_unused_network_from_coolify_proxy()
{
ray()->clearAll();
foreach ($this->servers as $server) {
if (! $server->isFunctional()) {
continue;
@@ -132,6 +139,7 @@ class Init extends Command
if (! $server->isProxyShouldRun()) {
continue;
}
try {
['networks' => $networks, 'allNetworks' => $allNetworks] = collectDockerNetworksByServer($server);
$removeNetworks = $allNetworks->diff($networks);
$commands = collect();
@@ -156,6 +164,9 @@ class Init extends Command
echo "Cleaning up unused networks from coolify proxy\n";
remote_process(command: $commands, type: ActivityTypes::INLINE->value, server: $server, ignore_errors: false);
}
} catch (\Throwable $e) {
echo "Error in cleaning up unused networks from coolify proxy: {$e->getMessage()}\n";
}
}
}
@@ -231,7 +242,6 @@ class Init extends Command
private function cleanup_in_progress_application_deployments()
{
// Cleanup any failed deployments
try {
if (isCloud()) {
return;