- 19 user-facing Router in 16 Modulen um middlewares = ["error-pages"] ergaenzt (502-504 -> Wartungsseite, analog CLD-1-Bestand): azess, azion-scheduler, bpi, n8n, pgadmin, phishboard, netbox (app + static), prtg/AZHA/AZDESK, grafana, technitium-dns, semaphore, kestra, online3dviewer, atrocore, stirling-pdf, excalidraw - Dokumentierte Ausnahmen (Kommentar am Router, Policy aus Brief): r.l-Dashboard (api-Router, Kontrollflaeche) und loki-push (Prometheus/Alloy brauchen echte Statuscodes) — bestehende Middleware-Listen unangetastet - Traefik errors-Middleware haelt den Original-Status 502-504 bei (keine statusRewrites) -> Blackbox-http_2xx-Probes auf g/wf/k/sem melden weiterhin Ausfaelle, keine zusaetzliche Metrik-Ausnahme noetig - Verifikation: nix eval aller 3 Hosts sauber; Router-Inspektion per jq bestaetigt 19x error-pages, api=auth, loki-push=loki-basic-auth
88 lines
2.0 KiB
Nix
88 lines
2.0 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
serviceName = "bpi";
|
|
servicePort = config.m3ta.ports.get serviceName;
|
|
appDir = "/var/lib/bpi/app";
|
|
in {
|
|
users.users.bpi = {
|
|
isSystemUser = true;
|
|
group = "bpi";
|
|
home = "/var/lib/bpi";
|
|
createHome = true;
|
|
};
|
|
users.groups.bpi = {};
|
|
|
|
systemd.services.bpi = {
|
|
description = "AZ INTEC Basispreis Index";
|
|
after = ["network-online.target"];
|
|
wants = ["network-online.target"];
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
path = with pkgs; [
|
|
git
|
|
nodejs
|
|
openssh
|
|
];
|
|
|
|
environment = {
|
|
PORT = toString servicePort;
|
|
HOME = "/var/lib/bpi";
|
|
BPI_BACKUP_DIR = "/var/lib/bpi/backups";
|
|
BPI_MAX_BACKUPS = "10";
|
|
};
|
|
|
|
preStart = ''
|
|
set -euo pipefail
|
|
|
|
if [ ! -d "${appDir}/.git" ]; then
|
|
rm -rf "${appDir}"
|
|
git clone --depth=1 https://git.az-gruppe.com/AZ-Intec-GmbH/BPI.git "${appDir}"
|
|
else
|
|
git -C "${appDir}" pull --ff-only
|
|
fi
|
|
|
|
if [ ! -f "${appDir}/server.js" ]; then
|
|
echo "${appDir}/server.js fehlt. Bitte server.js in das BPI Repository committen."
|
|
exit 1
|
|
fi
|
|
'';
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "bpi";
|
|
Group = "bpi";
|
|
StateDirectory = "bpi";
|
|
WorkingDirectory = "/var/lib/bpi";
|
|
ExecStart = "${pkgs.nodejs}/bin/node ${appDir}/server.js";
|
|
Restart = "on-failure";
|
|
RestartSec = "10s";
|
|
};
|
|
};
|
|
|
|
services.traefik.dynamicConfigOptions.http = {
|
|
services.bpi.loadBalancer.servers = [
|
|
{url = "http://localhost:${toString servicePort}/";}
|
|
];
|
|
|
|
routers.bpi = {
|
|
rule = "Host(`bpi.l.az-gruppe.com`)";
|
|
tls = {
|
|
certResolver = "ionos";
|
|
};
|
|
service = "bpi";
|
|
entrypoints = "websecure";
|
|
middlewares = ["error-pages"];
|
|
};
|
|
};
|
|
|
|
# Wartungsmodus: Selbstanmeldung des Dienstes (Q3).
|
|
m3ta.maintenance.services.bpi = {
|
|
domains = ["bpi.l.az-gruppe.com"];
|
|
desc = "BPI (Basispreis-Index)";
|
|
};
|
|
}
|