@@ -99,62 +99,73 @@ public function handle()
99
99
100
100
private function update_traefik_labels ()
101
101
{
102
- Server::where ('proxy->type ' , 'TRAEFIK_V2 ' )->update (['proxy->type ' => 'TRAEFIK ' ]);
102
+ try {
103
+ Server::where ('proxy->type ' , 'TRAEFIK_V2 ' )->update (['proxy->type ' => 'TRAEFIK ' ]);
104
+ } catch (\Throwable $ e ) {
105
+ echo "Error in updating traefik labels: {$ e ->getMessage ()}\n" ;
106
+ }
103
107
}
104
108
105
109
private function cleanup_unnecessary_dynamic_proxy_configuration ()
106
110
{
107
111
if (isCloud ()) {
108
112
foreach ($ this ->servers as $ server ) {
109
- if (! $ server ->isFunctional ()) {
110
- continue ;
111
- }
112
- if ($ server ->id === 0 ) {
113
- continue ;
114
- }
115
- $ file = $ server ->proxyPath ().'/dynamic/coolify.yaml ' ;
113
+ try {
114
+ if (! $ server ->isFunctional ()) {
115
+ continue ;
116
+ }
117
+ if ($ server ->id === 0 ) {
118
+ continue ;
119
+ }
120
+ $ file = $ server ->proxyPath ().'/dynamic/coolify.yaml ' ;
116
121
117
- return instant_remote_process ([
118
- "rm -f $ file " ,
119
- ], $ server , false );
122
+ return instant_remote_process ([
123
+ "rm -f $ file " ,
124
+ ], $ server , false );
125
+ } catch (\Throwable $ e ) {
126
+ echo "Error in cleaning up unnecessary dynamic proxy configuration: {$ e ->getMessage ()}\n" ;
127
+ }
120
128
121
129
}
122
130
}
123
131
}
124
132
125
133
private function cleanup_unused_network_from_coolify_proxy ()
126
134
{
127
- ray ()->clearAll ();
128
135
foreach ($ this ->servers as $ server ) {
129
136
if (! $ server ->isFunctional ()) {
130
137
continue ;
131
138
}
132
139
if (! $ server ->isProxyShouldRun ()) {
133
140
continue ;
134
141
}
135
- ['networks ' => $ networks , 'allNetworks ' => $ allNetworks ] = collectDockerNetworksByServer ($ server );
136
- $ removeNetworks = $ allNetworks ->diff ($ networks );
137
- $ commands = collect ();
138
- foreach ($ removeNetworks as $ network ) {
139
- $ out = instant_remote_process (["docker network inspect -f json $ network | jq '.[].Containers | if . == {} then null else . end' " ], $ server , false );
140
- if (empty ($ out )) {
141
- $ commands ->push ("docker network disconnect $ network coolify-proxy >/dev/null 2>&1 || true " );
142
- $ commands ->push ("docker network rm $ network >/dev/null 2>&1 || true " );
143
- } else {
144
- $ data = collect (json_decode ($ out , true ));
145
- if ($ data ->count () === 1 ) {
146
- // If only coolify-proxy itself is connected to that network (it should not be possible, but who knows)
147
- $ isCoolifyProxyItself = data_get ($ data ->first (), 'Name ' ) === 'coolify-proxy ' ;
148
- if ($ isCoolifyProxyItself ) {
149
- $ commands ->push ("docker network disconnect $ network coolify-proxy >/dev/null 2>&1 || true " );
150
- $ commands ->push ("docker network rm $ network >/dev/null 2>&1 || true " );
142
+ try {
143
+ ['networks ' => $ networks , 'allNetworks ' => $ allNetworks ] = collectDockerNetworksByServer ($ server );
144
+ $ removeNetworks = $ allNetworks ->diff ($ networks );
145
+ $ commands = collect ();
146
+ foreach ($ removeNetworks as $ network ) {
147
+ $ out = instant_remote_process (["docker network inspect -f json $ network | jq '.[].Containers | if . == {} then null else . end' " ], $ server , false );
148
+ if (empty ($ out )) {
149
+ $ commands ->push ("docker network disconnect $ network coolify-proxy >/dev/null 2>&1 || true " );
150
+ $ commands ->push ("docker network rm $ network >/dev/null 2>&1 || true " );
151
+ } else {
152
+ $ data = collect (json_decode ($ out , true ));
153
+ if ($ data ->count () === 1 ) {
154
+ // If only coolify-proxy itself is connected to that network (it should not be possible, but who knows)
155
+ $ isCoolifyProxyItself = data_get ($ data ->first (), 'Name ' ) === 'coolify-proxy ' ;
156
+ if ($ isCoolifyProxyItself ) {
157
+ $ commands ->push ("docker network disconnect $ network coolify-proxy >/dev/null 2>&1 || true " );
158
+ $ commands ->push ("docker network rm $ network >/dev/null 2>&1 || true " );
159
+ }
151
160
}
152
161
}
153
162
}
154
- }
155
- if ($ commands ->isNotEmpty ()) {
156
- echo "Cleaning up unused networks from coolify proxy \n" ;
157
- remote_process (command: $ commands , type: ActivityTypes::INLINE ->value , server: $ server , ignore_errors: false );
163
+ if ($ commands ->isNotEmpty ()) {
164
+ echo "Cleaning up unused networks from coolify proxy \n" ;
165
+ remote_process (command: $ commands , type: ActivityTypes::INLINE ->value , server: $ server , ignore_errors: false );
166
+ }
167
+ } catch (\Throwable $ e ) {
168
+ echo "Error in cleaning up unused networks from coolify proxy: {$ e ->getMessage ()}\n" ;
158
169
}
159
170
}
160
171
}
@@ -231,7 +242,6 @@ private function alive()
231
242
private function cleanup_in_progress_application_deployments ()
232
243
{
233
244
// Cleanup any failed deployments
234
-
235
245
try {
236
246
if (isCloud ()) {
237
247
return ;
0 commit comments