Merge pull request #2132 from coollabsio/next

v4.0.0-beta.274
This commit is contained in:
Andras Bacsai 2024-05-03 13:35:26 +02:00 committed by GitHub
commit b51747378a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 53 deletions

View File

@ -17,7 +17,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int|string|null $disk_usage = null; public int|string|null $disk_usage = null;
public $tries = 4; public $tries = 3;
public function backoff(): int public function backoff(): int
{ {
return isDev() ? 1 : 3; return isDev() ? 1 : 3;

View File

@ -10,7 +10,6 @@
use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Sleep;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes; use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
use Spatie\SchemalessAttributes\SchemalessAttributesTrait; use Spatie\SchemalessAttributes\SchemalessAttributesTrait;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -468,36 +467,40 @@ public function isServerReady(int $tries = 3)
if ($this->skipServer()) { if ($this->skipServer()) {
return false; return false;
} }
$checkIteration = 1; $serverUptimeCheckNumber = $this->unreachable_count;
$isServerReady = false; if ($this->unreachable_count < $tries) {
while ($checkIteration < $tries) { $serverUptimeCheckNumber = $this->unreachable_count + 1;
}
if ($this->unreachable_count > $tries) {
$serverUptimeCheckNumber = $tries;
}
$serverUptimeCheckNumberMax = $tries;
// ray('server: ' . $this->name);
// ray('serverUptimeCheckNumber: ' . $serverUptimeCheckNumber);
// ray('serverUptimeCheckNumberMax: ' . $serverUptimeCheckNumberMax);
['uptime' => $uptime] = $this->validateConnection(); ['uptime' => $uptime] = $this->validateConnection();
if ($uptime) { if ($uptime) {
if ($this->unreachable_notification_sent === true) { if ($this->unreachable_notification_sent === true) {
$this->update(['unreachable_notification_sent' => false]); $this->update(['unreachable_notification_sent' => false]);
} }
$this->settings()->update([ return true;
'is_reachable' => true,
]);
$isServerReady = true;
break;
} else { } else {
ray('Server is not ready yet.'); if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) {
$checkIteration++; // Reached max number of retries
Sleep::for(10)->seconds();
}
}
if ($isServerReady) {
return $isServerReady;
}
if ($this->unreachable_notification_sent === false) { if ($this->unreachable_notification_sent === false) {
ray('Server unreachable, sending notification...'); ray('Server unreachable, sending notification...');
$this->team?->notify(new Unreachable($this)); $this->team?->notify(new Unreachable($this));
$this->update(['unreachable_notification_sent' => true]); $this->update(['unreachable_notification_sent' => true]);
} }
if ($this->settings->is_reachable === true) {
$this->settings()->update([ $this->settings()->update([
'is_reachable' => false, 'is_reachable' => false,
]); ]);
}
foreach ($this->applications() as $application) { foreach ($this->applications() as $application) {
$application->update(['status' => 'exited']); $application->update(['status' => 'exited']);
} }
@ -514,8 +517,14 @@ public function isServerReady(int $tries = 3)
$db->update(['status' => 'exited']); $db->update(['status' => 'exited']);
} }
} }
} else {
$this->update([
'unreachable_count' => $this->unreachable_count + 1,
]);
}
return false; return false;
} }
}
public function getDiskUsage() public function getDiskUsage()
{ {
return instant_remote_process(["df /| tail -1 | awk '{ print $5}' | sed 's/%//g'"], $this, false); return instant_remote_process(["df /| tail -1 | awk '{ print $5}' | sed 's/%//g'"], $this, false);
@ -762,11 +771,6 @@ public function validateConnection()
$server->settings()->update([ $server->settings()->update([
'is_reachable' => false, 'is_reachable' => false,
]); ]);
if (data_get($server, 'unreachable_notification_sent') === false) {
ray('Server unreachable, sending notification...');
$this->team?->notify(new Unreachable($this));
$this->update(['unreachable_notification_sent' => true]);
}
return ['uptime' => false, 'error' => $e->getMessage()]; return ['uptime' => false, 'error' => $e->getMessage()];
} }
} }

View File

@ -7,7 +7,7 @@
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
'release' => '4.0.0-beta.273', 'release' => '4.0.0-beta.274',
// When left empty or `null` the Laravel environment will be used // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.273'; return '4.0.0-beta.274';

View File

@ -1,7 +1,7 @@
{ {
"coolify": { "coolify": {
"v4": { "v4": {
"version": "4.0.0-beta.273" "version": "4.0.0-beta.274"
} }
} }
} }