Skip to content

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.

Refactor server setting model to use waitBeforeDoingSshCheck method

Andras Bacsaicec77abaa8d4
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 3c6c32aa7c..01e480af5e 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -116,12 +116,7 @@ class Kernel extends ConsoleKernel
}
foreach ($servers as $server) {
$last_sentinel_update = $server->sentinel_updated_at;
- $push_interval_seconds = $server->settings->sentinel_push_interval_seconds;
- $wait_before_doing_ssh_check = $push_interval_seconds * 3;
- if ($wait_before_doing_ssh_check < 120) {
- $wait_before_doing_ssh_check = 120;
- }
- if (Carbon::parse($last_sentinel_update)->isBefore(now()->subSeconds($wait_before_doing_ssh_check))) {
+ if (Carbon::parse($last_sentinel_update)->isBefore(now()->subSeconds($server->waitBeforeDoingSshCheck()))) {
$schedule->job(new ServerCheckJob($server))->everyMinute()->onOneServer();
}
$serverTimezone = $server->settings->server_timezone;
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 50162a14cf..29bdabf3b4 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -535,9 +535,24 @@ $schema://$host {
$this->save();
}
+ /**
+ * Get the wait time before performing an SSH check.
+ *
+ * @return int The wait time in seconds.
+ */
+ public function waitBeforeDoingSshCheck(): int
+ {
+ $wait = $this->settings->sentinel_push_interval_seconds * 3;
+ if ($wait < 120) {
+ $wait = 120;
+ }
+
+ return $wait;
+ }
+
public function isSentinelLive()
{
- return Carbon::parse($this->sentinel_updated_at)->isAfter(now()->subMinutes(4));
+ return Carbon::parse($this->sentinel_updated_at)->isAfter(now()->subSeconds($this->waitBeforeDoingSshCheck()));
}
public function isSentinelEnabled()