Refactor server setting model to use waitBeforeDoingSshCheck method
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user