Initial commit: stats-gateway gRPC service + dashboard + CLI

This commit is contained in:
2026-05-05 21:04:32 +05:00
commit 4059e94759
44 changed files with 2513 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=stats-gateway probe collector
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=stats
Group=stats
ExecStart=/usr/local/bin/stats-collector --db /var/lib/stats-gateway/stats.db
StandardOutput=journal
StandardError=journal
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=stats-gateway probe every 5 minutes
[Timer]
OnBootSec=2min
OnUnitActiveSec=5min
RandomizedDelaySec=30s
Persistent=true
[Install]
WantedBy=timers.target
+24
View File
@@ -0,0 +1,24 @@
[Unit]
Description=stats-gateway gRPC service
After=network.target
Requires=network.target
[Service]
Type=simple
User=stats
Group=stats
ExecStart=/usr/local/bin/stats-gateway --addr 127.0.0.1:50051 --db /var/lib/stats-gateway/stats.db
Restart=on-failure
RestartSec=5s
StandardOutput=journal
StandardError=journal
# hardening
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/lib/stats-gateway
ProtectHome=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=Render stats-site templates and deploy to /var/www/stats-site
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/opt/stats-site/build.sh
StandardOutput=journal
StandardError=journal
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/www/stats-site
ProtectHome=true
PrivateTmp=true
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Run stats-site rebuild hourly
[Timer]
OnBootSec=5min
OnUnitActiveSec=1h
RandomizedDelaySec=2min
Persistent=true
[Install]
WantedBy=timers.target
+19
View File
@@ -0,0 +1,19 @@
[Unit]
Description=Generate stats snapshot.json for stats-site dashboard
After=stats-gateway.service
Wants=stats-gateway.service
[Service]
Type=oneshot
User=stats
Group=www-data
ExecStart=/usr/local/bin/stats-snapshot --db /var/lib/stats-gateway/stats.db --out /var/www/stats-site/data/snapshot.json
StandardOutput=journal
StandardError=journal
# Need write access to /var/www/stats-site/data
ReadWritePaths=/var/www/stats-site/data
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Run stats snapshot every 10 minutes
[Timer]
OnBootSec=3min
OnUnitActiveSec=10min
RandomizedDelaySec=30s
Persistent=true
[Install]
WantedBy=timers.target