fix: pull latest service-templates.json on init

This commit is contained in:
Andras Bacsai
2024-11-12 14:48:58 +01:00
parent 055c613ba5
commit 290cb45726

View File

@@ -57,12 +57,19 @@ class Init extends Command
$this->call('cleanup:stucked-resources'); $this->call('cleanup:stucked-resources');
if (isCloud()) { if (isCloud()) {
$response = Http::retry(3, 1000)->get(config('constants.services.official')); try {
if ($response->successful()) { $this->pullTemplatesFromCDN();
$services = $response->json(); } catch (\Throwable $e) {
File::put(base_path('templates/service-templates.json'), json_encode($services)); echo "Could not pull templates from CDN: {$e->getMessage()}\n";
}
}
if (! isCloud()) {
try {
$this->pullTemplatesFromCDN();
} catch (\Throwable $e) {
echo "Could not pull templates from CDN: {$e->getMessage()}\n";
} }
} else {
try { try {
$localhost = $this->servers->where('id', 0)->first(); $localhost = $this->servers->where('id', 0)->first();
$localhost->setupDynamicProxyConfiguration(); $localhost->setupDynamicProxyConfiguration();
@@ -80,6 +87,14 @@ class Init extends Command
} }
} }
private function pullTemplatesFromCDN()
{
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
if ($response->successful()) {
$services = $response->json();
File::put(base_path('templates/service-templates.json'), json_encode($services));
}
}
// private function disable_metrics() // private function disable_metrics()
// { // {
// if (version_compare('4.0.0-beta.312', config('version'), '<=')) { // if (version_compare('4.0.0-beta.312', config('version'), '<=')) {