Skip to content

Commit

Permalink
Refactor StartSentinel.php to use data_get() for retrieving server se…
Browse files Browse the repository at this point in the history
…ttings
  • Loading branch information
andrasbacsai committed Oct 15, 2024
1 parent 46ec8ee commit 8c53af0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
19 changes: 7 additions & 12 deletions app/Actions/Server/StartSentinel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@ public function handle(Server $server, $version = 'next', bool $restart = false)
if ($restart) {
StopSentinel::run($server);
}
$metrics_history = $server->settings->sentinel_metrics_history_days;
$refresh_rate = $server->settings->sentinel_metrics_refresh_rate_seconds;
$push_interval = $server->settings->sentinel_push_interval_seconds;
$token = $server->settings->sentinel_token;
$endpoint = InstanceSettings::get()->fqdn;
$metrics_history = data_get($server, 'settings.sentinel_metrics_history_days');
$refresh_rate = data_get($server, 'settings.sentinel_metrics_refresh_rate_seconds');
$push_interval = data_get($server, 'settings.sentinel_push_interval_seconds');
$token = data_get($server, 'settings.sentinel_token');
$endpoint = data_get($server, 'settings.sentinel_custom_url');
$mount_dir = '/data/coolify/sentinel';
$image = "ghcr.io/coollabsio/sentinel:$version";

if ($server->isLocalhost()) {
$endpoint = 'http://host.docker.internal:8000';
} else {
if (! $endpoint) {
throw new \Exception('You should set FQDN in Instance Settings.');
}
if (! $endpoint) {
throw new \Exception('You should set FQDN in Instance Settings.');
}
$environments = [
'TOKEN' => $token,
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,17 @@ public function forceDisableServer()

public function generateSentinelUrl() {
if ($this->isLocalhost()) {
return 'http://host.docker.internal:8888';
return 'http://host.docker.internal:8000';
}
$settings = InstanceSettings::get();
if ($settings->fqdn) {
return $settings->fqdn;
}
if ($settings->ipv4) {
return $settings->ipv4 . ':8888';
return $settings->ipv4 . ':8000';
}
if ($settings->ipv6) {
return $settings->ipv6 . ':8888';
return $settings->ipv6 . ':8000';
}
return null;
}
Expand Down

0 comments on commit 8c53af0

Please sign in to comment.