sdasd
This commit is contained in:
@@ -519,10 +519,26 @@ if (payloadNode) {
|
|||||||
const nextPoll = Number(data.poll_seconds || 5);
|
const nextPoll = Number(data.poll_seconds || 5);
|
||||||
|
|
||||||
updateGiteaTrayUi(state, message);
|
updateGiteaTrayUi(state, message);
|
||||||
|
emitDebug({
|
||||||
|
type: 'gitea:deploy-status',
|
||||||
|
source: 'gitea-addon',
|
||||||
|
status: response.status,
|
||||||
|
ok: response.ok,
|
||||||
|
message,
|
||||||
|
state,
|
||||||
|
poll_seconds: nextPoll,
|
||||||
|
diagnostics: data.diagnostics || null,
|
||||||
|
running_jobs: Array.isArray(data.running_jobs) ? data.running_jobs.length : 0,
|
||||||
|
});
|
||||||
scheduleGiteaStatusPoll(nextPoll);
|
scheduleGiteaStatusPoll(nextPoll);
|
||||||
return data;
|
return data;
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
updateGiteaTrayUi('error', 'Gitea-Deploy-Status konnte nicht geladen werden.');
|
updateGiteaTrayUi('error', 'Gitea-Deploy-Status konnte nicht geladen werden.');
|
||||||
|
emitDebug({
|
||||||
|
type: 'gitea:deploy-status:error',
|
||||||
|
source: 'gitea-addon',
|
||||||
|
message: 'Gitea-Deploy-Status konnte nicht geladen werden.',
|
||||||
|
});
|
||||||
scheduleGiteaStatusPoll(5);
|
scheduleGiteaStatusPoll(5);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ namespace App;
|
|||||||
|
|
||||||
final class ConfigLoader
|
final class ConfigLoader
|
||||||
{
|
{
|
||||||
|
public static function currentEnvironment(): string
|
||||||
|
{
|
||||||
|
return self::detectEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
@@ -14,7 +19,7 @@ final class ConfigLoader
|
|||||||
$basePath = $projectRoot . '/config/' . $name . '.php';
|
$basePath = $projectRoot . '/config/' . $name . '.php';
|
||||||
$config = is_file($basePath) ? require $basePath : [];
|
$config = is_file($basePath) ? require $basePath : [];
|
||||||
|
|
||||||
$appEnv = self::detectEnvironment();
|
$appEnv = self::currentEnvironment();
|
||||||
$envPath = $projectRoot . '/config/' . $appEnv . '/' . $name . '.php';
|
$envPath = $projectRoot . '/config/' . $appEnv . '/' . $name . '.php';
|
||||||
|
|
||||||
if (!is_file($envPath)) {
|
if (!is_file($envPath)) {
|
||||||
|
|||||||
@@ -38,6 +38,31 @@ final class GiteaDeployStatusService
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function diagnostics(): array
|
||||||
|
{
|
||||||
|
$repositories = array_values(array_filter(array_map(function (mixed $entry): ?string {
|
||||||
|
$normalized = $this->normalizeRepositoryEntry($entry);
|
||||||
|
|
||||||
|
return $normalized['full_name'] ?? null;
|
||||||
|
}, (array) ($this->config['repositories'] ?? []))));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'configured' => $this->isConfigured(),
|
||||||
|
'visibility' => $this->visibility(),
|
||||||
|
'base_url_present' => $this->baseUrl() !== '',
|
||||||
|
'base_url' => $this->baseUrl(),
|
||||||
|
'token_present' => $this->token() !== '',
|
||||||
|
'token_length' => strlen($this->token()),
|
||||||
|
'owner' => trim((string) ($this->config['owner'] ?? '')),
|
||||||
|
'repositories_configured' => $repositories,
|
||||||
|
'poll_idle_seconds' => max(1, (int) ($this->config['poll_idle_seconds'] ?? 5)),
|
||||||
|
'poll_running_seconds' => max(1, (int) ($this->config['poll_running_seconds'] ?? 1)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
@@ -53,6 +78,7 @@ final class GiteaDeployStatusService
|
|||||||
'message' => 'Gitea-Status ist noch nicht konfiguriert.',
|
'message' => 'Gitea-Status ist noch nicht konfiguriert.',
|
||||||
'running_jobs' => [],
|
'running_jobs' => [],
|
||||||
'repositories_checked' => 0,
|
'repositories_checked' => 0,
|
||||||
|
'diagnostics' => $this->diagnostics(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +122,7 @@ final class GiteaDeployStatusService
|
|||||||
'message' => $message,
|
'message' => $message,
|
||||||
'running_jobs' => $runningJobs,
|
'running_jobs' => $runningJobs,
|
||||||
'repositories_checked' => count($repositories),
|
'repositories_checked' => count($repositories),
|
||||||
|
'diagnostics' => $this->diagnostics(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +132,7 @@ final class GiteaDeployStatusService
|
|||||||
'message' => sprintf('Kein laufendes Gitea-Deployment in %d Repositories.', count($repositories)),
|
'message' => sprintf('Kein laufendes Gitea-Deployment in %d Repositories.', count($repositories)),
|
||||||
'running_jobs' => [],
|
'running_jobs' => [],
|
||||||
'repositories_checked' => count($repositories),
|
'repositories_checked' => count($repositories),
|
||||||
|
'diagnostics' => $this->diagnostics(),
|
||||||
];
|
];
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
return [
|
return [
|
||||||
@@ -113,6 +141,7 @@ final class GiteaDeployStatusService
|
|||||||
'message' => 'Gitea-Status konnte nicht geladen werden: ' . $exception->getMessage(),
|
'message' => 'Gitea-Status konnte nicht geladen werden: ' . $exception->getMessage(),
|
||||||
'running_jobs' => [],
|
'running_jobs' => [],
|
||||||
'repositories_checked' => 0,
|
'repositories_checked' => 0,
|
||||||
|
'diagnostics' => $this->diagnostics(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ $groups = array_values(array_map('strval', (array) ($authUser['groups'] ?? [])))
|
|||||||
$isAdmin = in_array('administrators', $groups, true);
|
$isAdmin = in_array('administrators', $groups, true);
|
||||||
|
|
||||||
$projectRoot = dirname(__DIR__, 3);
|
$projectRoot = dirname(__DIR__, 3);
|
||||||
|
$currentEnvironment = ConfigLoader::currentEnvironment();
|
||||||
$service = new GiteaDeployStatusService(ConfigLoader::load($projectRoot, 'gitea'));
|
$service = new GiteaDeployStatusService(ConfigLoader::load($projectRoot, 'gitea'));
|
||||||
|
|
||||||
if (!$service->shouldShowInTray($isAdmin)) {
|
if (!$service->shouldShowInTray($isAdmin)) {
|
||||||
@@ -24,8 +25,14 @@ if (!$service->shouldShowInTray($isAdmin)) {
|
|||||||
], 403);
|
], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$status = $service->status();
|
||||||
|
$diagnostics = is_array($status['diagnostics'] ?? null) ? $status['diagnostics'] : [];
|
||||||
|
$diagnostics['environment'] = $currentEnvironment;
|
||||||
|
$diagnostics['host'] = (string) ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? '');
|
||||||
|
$status['diagnostics'] = $diagnostics;
|
||||||
|
|
||||||
respond([
|
respond([
|
||||||
'data' => $service->status(),
|
'data' => $status,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user