An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
revert server checking fn
Andras Bacsai424a6b04282c
diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.phpindex d91961bcb5..63033d7b80 100644--- a/app/Jobs/ServerStatusJob.php+++ b/app/Jobs/ServerStatusJob.php@@ -17,7 +17,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypteduse Dispatchable, InteractsWithQueue, Queueable, SerializesModels;public int|string|null $disk_usage = null;- public $tries = 4;+ public $tries = 3;public function backoff(): int{return isDev() ? 1 : 3;diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 54cc134aa9..19da8d7842 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Casts\Attribute;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Storage;-use Illuminate\Support\Sleep;use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;use Spatie\SchemalessAttributes\SchemalessAttributesTrait;use Illuminate\Support\Str;@@ -468,53 +467,63 @@ $schema://$host {if ($this->skipServer()) {return false;}- $checkIteration = 1;- $isServerReady = false;- while ($checkIteration < $tries) {- ['uptime' => $uptime] = $this->validateConnection();- if ($uptime) {- if ($this->unreachable_notification_sent === true) {- $this->update(['unreachable_notification_sent' => false]);- }- $this->settings()->update([- 'is_reachable' => true,- ]);- $isServerReady = true;- break;- } else {- ray('Server is not ready yet.');- $checkIteration++;- Sleep::for(10)->seconds();- }- }- if ($isServerReady) {- return $isServerReady;- }- if ($this->unreachable_notification_sent === false) {- ray('Server unreachable, sending notification...');- $this->team?->notify(new Unreachable($this));- $this->update(['unreachable_notification_sent' => true]);+ $serverUptimeCheckNumber = $this->unreachable_count;+ if ($this->unreachable_count < $tries) {+ $serverUptimeCheckNumber = $this->unreachable_count + 1;}- $this->settings()->update([- 'is_reachable' => false,- ]);- foreach ($this->applications() as $application) {- $application->update(['status' => 'exited']);- }- foreach ($this->databases() as $database) {- $database->update(['status' => 'exited']);+ if ($this->unreachable_count > $tries) {+ $serverUptimeCheckNumber = $tries;}- foreach ($this->services()->get() as $service) {- $apps = $service->applications()->get();- $dbs = $service->databases()->get();- foreach ($apps as $app) {- $app->update(['status' => 'exited']);++ $serverUptimeCheckNumberMax = $tries;++ // ray('server: ' . $this->name);+ // ray('serverUptimeCheckNumber: ' . $serverUptimeCheckNumber);+ // ray('serverUptimeCheckNumberMax: ' . $serverUptimeCheckNumberMax);++ ['uptime' => $uptime] = $this->validateConnection();+ if ($uptime) {+ if ($this->unreachable_notification_sent === true) {+ $this->update(['unreachable_notification_sent' => false]);}- foreach ($dbs as $db) {- $db->update(['status' => 'exited']);+ return true;+ } else {+ if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) {+ // Reached max number of retries+ if ($this->unreachable_notification_sent === false) {+ ray('Server unreachable, sending notification...');+ $this->team?->notify(new Unreachable($this));+ $this->update(['unreachable_notification_sent' => true]);+ }+ if ($this->settings->is_reachable === true) {+ $this->settings()->update([+ 'is_reachable' => false,+ ]);+ }++ foreach ($this->applications() as $application) {+ $application->update(['status' => 'exited']);+ }+ foreach ($this->databases() as $database) {+ $database->update(['status' => 'exited']);+ }+ foreach ($this->services()->get() as $service) {+ $apps = $service->applications()->get();+ $dbs = $service->databases()->get();+ foreach ($apps as $app) {+ $app->update(['status' => 'exited']);+ }+ foreach ($dbs as $db) {+ $db->update(['status' => 'exited']);+ }+ }+ } else {+ $this->update([+ 'unreachable_count' => $this->unreachable_count + 1,+ ]);}+ return false;}- return false;}public function getDiskUsage(){@@ -762,11 +771,6 @@ $schema://$host {$server->settings()->update(['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()];}}diff --git a/config/sentry.php b/config/sentry.phpindex 6629fefab3..633e5bcd61 100644--- a/config/sentry.php+++ b/config/sentry.php@@ -7,7 +7,7 @@ return [// The release version of your application// 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'environment' => config('app.env'),diff --git a/config/version.php b/config/version.phpindex a5706892f7..3cb55c8fde 100644--- a/config/version.php+++ b/config/version.php@@ -1,3 +1,3 @@<?php-return '4.0.0-beta.273';+return '4.0.0-beta.274';diff --git a/versions.json b/versions.jsonindex fee22c51df..2225d2fbcd 100644--- a/versions.json+++ b/versions.json@@ -1,7 +1,7 @@{"coolify": {"v4": {- "version": "4.0.0-beta.273"+ "version": "4.0.0-beta.274"}}}