Run gghstats serve under systemd on Linux. Configuration is an environment file at /etc/gghstats/gghstats.env.
macOS (local LaunchAgent): see contrib/launchd/README.md.
One instance = one SQLite file and one filter. For multiple isolated dashboards, use separate env files, units, and data directories (e.g. gghstats-team-a.service + /etc/gghstats/team-a.env).
-
Environment file β .deb/.rpm install
contrib/gghstats.env.exampleto/etc/gghstats/gghstats.env. From source:sudo mkdir -p /etc/gghstats /var/lib/gghstats sudo cp contrib/gghstats.env.example /etc/gghstats/gghstats.env # Edit: GGHSTATS_GITHUB_TOKEN, GGHSTATS_FILTER, GGHSTATS_DB, etc. sudo chmod 600 /etc/gghstats/gghstats.env -
Binary path β Units use
/usr/bin/gghstats(where .deb/.rpm install). For manual install to/usr/local/bin, editExecStartin the unit. -
Data directory β Default
/var/lib/gghstats(WorkingDirectory+GGHSTATS_DB=/var/lib/gghstats/gghstats.db). Create and own it if using a dedicated user:sudo chown -R gghstats:gghstats /var/lib/gghstats
The binary default when
GGHSTATS_DBis unset is now the platform config dir (Linux~/.config/gghstats/, macOS~/Library/Application Support/gghstats/). Always set an absolute path in the env file for systemd. See root README β Data directory (SQLite paths).
| Unit | Function |
|---|---|
gghstats.service |
Daemon β HTTP UI, scheduled GitHub sync, SQLite storage |
.deb/.rpm install the unit to /lib/systemd/system/. Skip the cp step below; enable and start only.
Units order after network.target (not network-online.target). That avoids systemctl enable --now appearing to hang while systemd waits for systemd-networkd-wait-online (common on minimal or static-IP installs). GitHub API calls still need working DNS/routing before sync succeeds.
# Validate token and filter without enabling systemd (uses your shell env or a copy of the env file)
set -a && source /etc/gghstats/gghstats.env && set +a
gghstats serve
# Ctrl+C when OK, then enable the unit# .deb/.rpm: units already in /lib/systemd/system/
# From source:
# sudo cp contrib/systemd/gghstats.service /etc/systemd/system/
# If manual install: edit ExecStart=/usr/local/bin/gghstats serve
sudo systemctl daemon-reload
sudo systemctl enable --now gghstats
journalctl -u gghstats -fsudo useradd -r -d /var/lib/gghstats -s /usr/sbin/nologin gghstats
sudo chown -R gghstats:gghstats /var/lib/gghstats
sudo chmod 600 /etc/gghstats/gghstats.env
sudo chown root:gghstats /etc/gghstats/gghstats.env # or root:root if only root reads secretsUncomment in gghstats.service:
User=gghstats
Group=gghstatsEnsure gghstats can read /etc/gghstats/gghstats.env and read/write /var/lib/gghstats.
GGHSTATS_HOST |
Use when |
|---|---|
127.0.0.1 |
Reverse proxy (nginx, Traefik, Caddy) on the same host β recommended for servers |
0.0.0.0 |
Direct access on all interfaces (firewall carefully) |
| Public HTTPS, Traefik, Compose stacks | gghstats-selfhosted β preferred for production |
| Bare metal + systemd (this unit) | 127.0.0.1 + optional reverse proxy on the same host |
| Dev Docker in the gghstats repo | Local smoke test only β not production |
gghstats-selfhosted Compose sets 0.0.0.0 inside the container; that is separate from this bare-metal unit.
Release packages run maintainer scripts on uninstall:
| Action | Behaviour |
|---|---|
apt remove / dnf remove |
Stops and disables gghstats.service; keeps /etc/gghstats/gghstats.env and /var/lib/gghstats |
apt purge |
Same as remove, then deletes /etc/gghstats/ (config only; not /var/lib/gghstats) |
Scripts: contrib/deb/prerm.sh, contrib/deb/postrm.sh.
Often network-online.target on an older copied unit. Use current contrib/systemd/gghstats.service (network.target), then:
sudo systemctl daemon-reload
sudo systemctl reset-failed gghstats.service
sudo systemctl start gghstats.service
sudo systemctl status gghstats.serviceDrop-in override without replacing the unit:
sudo mkdir -p /etc/systemd/system/gghstats.service.d
sudo tee /etc/systemd/system/gghstats.service.d/override.conf << 'EOF'
[Unit]
After=network.target
Wants=network.target
EOF
sudo systemctl daemon-reload
sudo systemctl reset-failed gghstats.service
sudo systemctl start gghstats.serviceGGHSTATS_GITHUB_TOKEN is requiredβ set token in/etc/gghstats/gghstats.env.- SQLite permission denied β fix ownership of
/var/lib/gghstatsfor the unitUser=. ExecStartnot found β binary is under/usr/local/bin; update the unit or symlink to/usr/bin/gghstats.
journalctl -u gghstats stays empty until systemd has started the process at least once.