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
Fix: Prevent ServerStorageCheckJob duplication when Sentinel is active
Andras Bacsai56a0143a25af
diff --git a/app/Jobs/ServerManagerJob.php b/app/Jobs/ServerManagerJob.phpindex 4a1cb05a35..53ee272bbf 100644--- a/app/Jobs/ServerManagerJob.php+++ b/app/Jobs/ServerManagerJob.php@@ -139,15 +139,18 @@ class ServerManagerJob implements ShouldQueue});}- // Dispatch ServerStorageCheckJob if due (independent of Sentinel status)- $serverDiskUsageCheckFrequency = data_get($server->settings, 'server_disk_usage_check_frequency', '0 23 * * *');- if (isset(VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency])) {- $serverDiskUsageCheckFrequency = VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency];- }- $shouldRunStorageCheck = $this->shouldRunNow($serverDiskUsageCheckFrequency, $serverTimezone);+ // Dispatch ServerStorageCheckJob if due (only when Sentinel is out of sync or disabled)+ // When Sentinel is active, PushServerUpdateJob handles storage checks with real-time data+ if ($sentinelOutOfSync) {+ $serverDiskUsageCheckFrequency = data_get($server->settings, 'server_disk_usage_check_frequency', '0 23 * * *');+ if (isset(VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency])) {+ $serverDiskUsageCheckFrequency = VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency];+ }+ $shouldRunStorageCheck = $this->shouldRunNow($serverDiskUsageCheckFrequency, $serverTimezone);- if ($shouldRunStorageCheck) {- ServerStorageCheckJob::dispatch($server);+ if ($shouldRunStorageCheck) {+ ServerStorageCheckJob::dispatch($server);+ }}// Dispatch ServerPatchCheckJob if due (weekly)diff --git a/tests/Feature/ServerStorageCheckIndependenceTest.php b/tests/Feature/ServerStorageCheckIndependenceTest.phpindex a6b18469d2..d5b8b79f64 100644--- a/tests/Feature/ServerStorageCheckIndependenceTest.php+++ b/tests/Feature/ServerStorageCheckIndependenceTest.php@@ -19,7 +19,7 @@ afterEach(function () {Carbon::setTestNow();});-it('dispatches storage check when sentinel is in sync', function () {+it('does not dispatch storage check when sentinel is in sync', function () {// Given: A server with Sentinel recently updated (in sync)$team = Team::factory()->create();$server = Server::factory()->create([@@ -37,10 +37,8 @@ it('dispatches storage check when sentinel is in sync', function () {$job = new ServerManagerJob;$job->handle();- // Then: ServerStorageCheckJob should be dispatched- Queue::assertPushed(ServerStorageCheckJob::class, function ($job) use ($server) {- return $job->server->id === $server->id;- });+ // Then: ServerStorageCheckJob should NOT be dispatched (Sentinel handles it via PushServerUpdateJob)+ Queue::assertNotPushed(ServerStorageCheckJob::class);});it('dispatches storage check when sentinel is out of sync', function () {@@ -93,12 +91,12 @@ it('dispatches storage check when sentinel is disabled', function () {});});-it('respects custom hourly storage check frequency', function () {- // Given: A server with hourly storage check frequency+it('respects custom hourly storage check frequency when sentinel is out of sync', function () {+ // Given: A server with hourly storage check frequency and Sentinel out of sync$team = Team::factory()->create();$server = Server::factory()->create(['team_id' => $team->id,- 'sentinel_updated_at' => now(),+ 'sentinel_updated_at' => now()->subMinutes(10),]);$server->settings->update([@@ -117,12 +115,12 @@ it('respects custom hourly storage check frequency', function () {});});-it('handles VALID_CRON_STRINGS mapping correctly', function () {- // Given: A server with 'hourly' string (should be converted to '0 * * * *')+it('handles VALID_CRON_STRINGS mapping correctly when sentinel is out of sync', function () {+ // Given: A server with 'hourly' string (should be converted to '0 * * * *') and Sentinel out of sync$team = Team::factory()->create();$server = Server::factory()->create(['team_id' => $team->id,- 'sentinel_updated_at' => now(),+ 'sentinel_updated_at' => now()->subMinutes(10),]);$server->settings->update([@@ -141,12 +139,12 @@ it('handles VALID_CRON_STRINGS mapping correctly', function () {});});-it('respects server timezone for storage checks', function () {- // Given: A server in America/New_York timezone (UTC-5) configured for 11 PM local time+it('respects server timezone for storage checks when sentinel is out of sync', function () {+ // Given: A server in America/New_York timezone (UTC-5) configured for 11 PM local time and Sentinel out of sync$team = Team::factory()->create();$server = Server::factory()->create(['team_id' => $team->id,- 'sentinel_updated_at' => now(),+ 'sentinel_updated_at' => now()->subMinutes(10),]);$server->settings->update([