This commit is contained in:
Andras Bacsai
2024-10-17 22:08:23 +02:00
parent 9044c655b8
commit b75c2dc604
18 changed files with 62 additions and 51 deletions

View File

@@ -51,7 +51,6 @@ class ScheduledDatabaseBackup extends BaseModel
}
}
return null;
}
}

View File

@@ -169,7 +169,7 @@ class Server extends BaseModel
public function setupDefault404Redirect()
{
$dynamic_conf_path = $this->proxyPath() . '/dynamic';
$dynamic_conf_path = $this->proxyPath().'/dynamic';
$proxy_type = $this->proxyType();
$redirect_url = $this->proxy->redirect_url;
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
@@ -183,8 +183,8 @@ class Server extends BaseModel
respond 404
}';
$conf =
"# This file is automatically generated by Coolify.\n" .
"# Do not edit it manually (only if you know what are you doing).\n\n" .
"# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n".
$conf;
$base64 = base64_encode($conf);
instant_remote_process([
@@ -246,8 +246,8 @@ respond 404
];
$conf = Yaml::dump($dynamic_conf, 12, 2);
$conf =
"# This file is automatically generated by Coolify.\n" .
"# Do not edit it manually (only if you know what are you doing).\n\n" .
"# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n".
$conf;
$base64 = base64_encode($conf);
@@ -256,8 +256,8 @@ respond 404
redir $redirect_url
}";
$conf =
"# This file is automatically generated by Coolify.\n" .
"# Do not edit it manually (only if you know what are you doing).\n\n" .
"# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n".
$conf;
$base64 = base64_encode($conf);
}
@@ -275,7 +275,7 @@ respond 404
public function setupDynamicProxyConfiguration()
{
$settings = instanceSettings();
$dynamic_config_path = $this->proxyPath() . '/dynamic';
$dynamic_config_path = $this->proxyPath().'/dynamic';
if ($this->proxyType() === ProxyTypes::TRAEFIK->value) {
$file = "$dynamic_config_path/coolify.yaml";
if (empty($settings->fqdn) || (isCloud() && $this->id !== 0) || ! $this->isLocalhost()) {
@@ -394,8 +394,8 @@ respond 404
}
$yaml = Yaml::dump($traefik_dynamic_conf, 12, 2);
$yaml =
"# This file is automatically generated by Coolify.\n" .
"# Do not edit it manually (only if you know what are you doing).\n\n" .
"# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n".
$yaml;
$base64 = base64_encode($yaml);
@@ -459,13 +459,13 @@ $schema://$host {
if (isDev()) {
$proxy_path = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/proxy/caddy';
} else {
$proxy_path = $proxy_path . '/caddy';
$proxy_path = $proxy_path.'/caddy';
}
} elseif ($proxyType === ProxyTypes::NGINX->value) {
if (isDev()) {
$proxy_path = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/proxy/nginx';
} else {
$proxy_path = $proxy_path . '/nginx';
$proxy_path = $proxy_path.'/nginx';
}
}
@@ -528,12 +528,12 @@ $schema://$host {
Storage::disk('ssh-mux')->delete($this->muxFilename());
}
public function sentinelHeartbeat(bool $isReset = false)
{
$this->sentinel_updated_at = $isReset ? now()->subMinutes(6000) : now();
$this->sentinel_updated_at = $isReset ? now()->subMinutes(6000) : now();
$this->save();
}
public function isSentinelLive()
{
return Carbon::parse($this->sentinel_updated_at)->isAfter(now()->subMinutes(4));
@@ -541,7 +541,7 @@ $schema://$host {
public function isSentinelEnabled()
{
return ($this->isMetricsEnabled() || $this->isServerApiEnabled()) && !$this->isBuildServer();
return ($this->isMetricsEnabled() || $this->isServerApiEnabled()) && ! $this->isBuildServer();
}
public function isMetricsEnabled()
@@ -611,8 +611,9 @@ $schema://$host {
}
$cpu = json_decode($cpu, true);
$parsedCollection = collect($cpu)->map(function ($metric) {
return [(int)$metric['time'], (float)$metric['percent']];
return [(int) $metric['time'], (float) $metric['percent']];
});
return $parsedCollection;
}
@@ -640,8 +641,8 @@ $schema://$host {
throw new \Exception($error);
}
$memory = json_decode($memory, true);
$parsedCollection = collect($memory)->map(function ($metric) {
return [(int)$metric['time'], (float)$metric['usedPercent']];
$parsedCollection = collect($memory)->map(function ($metric) {
return [(int) $metric['time'], (float) $metric['usedPercent']];
});
return $parsedCollection->toArray();
@@ -1092,6 +1093,7 @@ $schema://$host {
return true;
}
public function validateConnection($isManualCheck = true)
{
config()->set('constants.ssh.mux_enabled', ! $isManualCheck);

View File

@@ -72,7 +72,7 @@ class ServerSetting extends Model
}
}
} catch (\Throwable $e) {
loggy('Error creating server setting: ' . $e->getMessage());
loggy('Error creating server setting: '.$e->getMessage());
}
});
}
@@ -98,17 +98,18 @@ class ServerSetting extends Model
$settings = InstanceSettings::get();
if ($this->server->isLocalhost()) {
$domain = 'http://host.docker.internal:8000';
} else if ($settings->fqdn) {
} elseif ($settings->fqdn) {
$domain = $settings->fqdn;
} else if ($settings->ipv4) {
$domain = $settings->ipv4 . ':8000';
} else if ($settings->ipv6) {
$domain = $settings->ipv6 . ':8000';
} elseif ($settings->ipv4) {
$domain = $settings->ipv4.':8000';
} elseif ($settings->ipv6) {
$domain = $settings->ipv6.':8000';
}
$this->sentinel_custom_url = $domain;
if ($save) {
$this->save();
}
return $domain;
}

View File

@@ -297,7 +297,7 @@ class Service extends BaseModel
'key' => 'CP_DISABLE_HTTPS',
'value' => data_get($disable_https, 'value'),
'rules' => 'required',
'customHelper' => "If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS",
'customHelper' => 'If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS',
],
]);
}
@@ -997,8 +997,8 @@ class Service extends BaseModel
break;
case $image->contains('mysql'):
$userVariables = ['SERVICE_USER_MYSQL', 'SERVICE_USER_WORDPRESS', 'MYSQL_USER'];
$passwordVariables = ['SERVICE_PASSWORD_MYSQL', 'SERVICE_PASSWORD_WORDPRESS', 'MYSQL_PASSWORD','SERVICE_PASSWORD_64_MYSQL'];
$rootPasswordVariables = ['SERVICE_PASSWORD_MYSQLROOT', 'SERVICE_PASSWORD_ROOT','SERVICE_PASSWORD_64_MYSQLROOT'];
$passwordVariables = ['SERVICE_PASSWORD_MYSQL', 'SERVICE_PASSWORD_WORDPRESS', 'MYSQL_PASSWORD', 'SERVICE_PASSWORD_64_MYSQL'];
$rootPasswordVariables = ['SERVICE_PASSWORD_MYSQLROOT', 'SERVICE_PASSWORD_ROOT', 'SERVICE_PASSWORD_64_MYSQLROOT'];
$dbNameVariables = ['MYSQL_DATABASE'];
$mysql_user = $this->environment_variables()->whereIn('key', $userVariables)->first();
$mysql_password = $this->environment_variables()->whereIn('key', $passwordVariables)->first();
@@ -1326,9 +1326,9 @@ class Service extends BaseModel
return false;
}
}
return true;
}
);
}
}