Skip to content
elvin-liPublic

About

A macOS home-server management panel built with FastAPI, Vue 3, and a native menu-bar app.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

ServerHub v3.9.5

English | 简体中文

A low-overhead, SSD-friendly home-server management panel built specifically for macOS & Apple Silicon — combining Unraid-style storage and share workflows with Activity Monitor telemetry, Apple Container / OrbStack management, native LaunchAgent / Homebrew orchestration, and zero-dependency built-in security.

Default bind: 127.0.0.1:8086 (loopback only). Set SERVERHUB_HOST=0.0.0.0 for LAN access. Mandatory authentication is enforced once first-run setup completes. Never expose port 8086 raw to the public internet — place it behind a Cloudflare Tunnel, WireGuard, or a TLS-terminating reverse proxy.


Screenshots

All screenshots below are rendered from the real Vue 3 SPA against 100% fictional demo data — no real hostnames, IP addresses, accounts, tokens, disk serials, or personal paths are included.

System Overview — macOS Light Theme (English)

ServerHub system overview in the macOS light theme

System Overview — macOS Dark Theme (简体中文)

ServerHub system overview in the macOS dark theme (Simplified Chinese)

Apple Container Engine & XiaomiHub Gateway Management

ServerHub Apple Container and XiaomiHub management view

File Sharing, Filesystem ACLs & Time Machine Quotas

ServerHub SMB Shares and Time Machine destination quotas

One-Click App Store (Native macOS & Container Templates)

ServerHub 50-template App Store catalog


Highlights & Feature Matrix

Domain Capabilities Documentation
Dashboard & Telemetry Activity-Monitor-style twin CPU & Apple GPU plots, unified memory breakdown (App / Wired / Compressed / Cached), NVMe SMART wear & temperature,UPS chip, local LLM chip, and tiered metrics (90s / 5m / 1h from 1 hour to 1 year) docs/metrics.md
Storage & Pool Physical disk inventory, format/mount/eject with device-identity guards, NVMe/SATA SMART self-tests, AppleRAID, JBOD Union Pool placement planning, APFS snapshots, directory usage analytics —
Shares & Time Machine Native macOS SMB share CRUD (guest, read-only, SMB encryption), Time Machine network backup destinations with per-share GB quotas, per-user filesystem ACL editor, NFS exports, macOS System Sharing toggles (Screen Sharing, SSH) docs/time-machine.md
Containers & App Store Dual engine support (Apple container on macOS Virtualization.framework + OrbStack / Docker), idle BuildKit VM auto-reaper, XiaomiHub central gateway lifecycle & role telemetry, Dockge-style Compose editor, 50 built-in templates (native Homebrew/GPU + container stacks) + optional SHA-256-pinned remote catalog docs/app-catalog.md
Services & Native Stack Auto-discovery across launchd, Homebrew, containers, UTM/Orb VMs, and listening ports; one-click adoption, log tailing, native Immich (Metal/ANE + VideoToolbox) health checks, and PhotosHub bridge management docs/app-catalog.md
Local AI & In-Panel Assistant Ollama / mlx-lm model management, live streaming chat/test bench, and built-in Assist / Explain This Page copilot across English, Simplified Chinese, and Japanese —
Networking & Edge Interface order, DHCP/static IP, virtual IP aliases with auto-bind, wired/Wi-Fi automatic failover, WireGuard peers + QR/conf export + pf NAT + wstunnel obfuscation, Cloudflare Tunnel, Nginx gateway, and automatic Local Sites discovery (/sites) —
Scheduler & Backups Built-in cron scheduler (shell, rsync, Compose stack backup, APFS snapshot), rsync dry-run preview, crash-safe stack backups, external-volume-first PostgreSQL & config archives docs/scheduler-and-backups.md
UPS & Power Safety Native USB UPS monitoring (pmset), AC-loss / low-battery alerts, and a two-layer safe-shutdown policy (ordered graceful workload stop + dry-run drill + automatic power-return restore) docs/ups.md
Notifications Multi-channel alert routing across SMTP, ntfy, Telegram, Discord, Slack, generic Webhooks, and Home Assistant with per-channel severity thresholds and secret redaction docs/notifications.md
Security & Multi-User Mandatory setup-token bootstrap, Admin & Member roles with per-service grants, TOTP 2FA + recovery codes, SHA-256 hashed API keys, append-only auth audit log, SSRF & WebSocket origin guards docs/authentication.md
Tools & Diagnostics Audited Web Terminal (host PTY + container exec) with lazy-loaded xterm.js, one-click redacted diagnostics bundle, syslog viewer, LaunchAgent inspector, panel & Homebrew updater docs/upgrade.md

Engineered for Low Overhead & Minimal SSD Wear

Home servers on Apple Silicon run 24/7 on soldered internal NVMe storage. ServerHub is explicitly architected to keep idle CPU, RAM, and NAND write amplification near zero:

  • Zero-Tempfile Subprocess Capture: Bounded pipe + selectors capture (hub/util.py) reads CLI output in memory without creating /tmp files on every poll.
  • Batched Telemetry & Write Guards: Metrics buffer in RAM and flush/roll up on a 30-minute cadence (fsync=False on non-critical telemetry); state caches (brew_cache, alerts, metrics_rollup) skip disk rewrites when bytes are unchanged.
  • 1 Hz Quiet Event Loop & In-Process libproc: Custom uvicorn tick (hub/quiet_server.py) + direct macOS libproc / sysctl reads avoid spawning ps or top during background ticks.
  • Auto-Reaped Ephemeral VMs: Idle Apple Container buildkit VMs are detected in-memory via psutil and automatically stopped once builds complete, reclaiming 2 GiB RAM without deleting cached image layers.
  • Sub-90 KiB First-Paint SPA: Every route (including / and /login), xterm.js, QR generator, and locale dictionary (en / zh-CN / ja) is code-split; vite build hard-fails if the entry bundle ever exceeds 150 KiB.

Architecture & Tech Stack

  • Backend: Python 3.10+ / FastAPI (hub/, entry app.py), standard-library TOTP, scrypt password hashing, API-key hashing, cron matcher, and notification senders (no heavy auth/ORM/crypto bloat).
  • Frontend: Vue 3.5 + Vite 6 (web/ → prebuilt static/), zero Options API runtime, 3 themes (macOS, Unraid, Docker in Light/Dark/System) and 3 locales (English, 简体中文, 日本語).
  • Container Engines: First-class support for both Apple container (container_engine: apple) and OrbStack / Docker (container_engine: docker), selectable in services.yaml or Settings.
  • Native macOS Menu Bar App: Pure AppKit Swift launcher (macos/ServerHubLauncher.swift → ServerHub.app) using ephemeral zero-disk-cache URLSession, non-modal alert sessions, sleep/wake pause, and automatic backoff.

Quick Start

Requires macOS 13+ and Python 3.10+. (Prebuilt SPA assets ship in static/; Node.js 20/22+ is only needed when editing web/.)

git clone https://github.com/elvin-li/ServerHub.git
cd ServerHub
./install.sh
open http://localhost:8086
  1. ./install.sh creates .venv, preserves any existing services.yaml and data/, installs and bootstraps local.serverhub.panel + local.serverhub.watchdog, and generates a one-time data/.setup-token (0600).
  2. Visiting http://localhost:8086 from the same Mac auto-supplies the setup token so you can create the administrator account immediately. When connecting through a reverse proxy or Cloudflare Tunnel, paste the token from data/.setup-token.
  3. To uninstall: ./uninstall.sh (append --purge to also delete local services.yaml and data/).

Environment Variables

Variable Default Purpose
SERVERHUB_HOST 127.0.0.1 Listen address (0.0.0.0 to allow LAN access)
SERVERHUB_PORT 8086 HTTP listen port
SERVERHUB_STATE_DIR repo root Directory holding mutable services.yaml and data/
SERVERHUB_LOG_DIR ~/Library/Logs Target directory for deploy/run-panel.py stdout/stderr logs (supports external-volume symlinks)
SERVERHUB_TRUSTED_PROXIES 127.0.0.1/32,::1/128 Reverse-proxy CIDRs trusted for X-Forwarded-For / CF-Connecting-IP client attribution

Health probes:

  • GET /ready — unauthenticated zero-discovery readiness probe.
  • GET /api/health — lightweight watchdog liveness probe.
  • GET /api/status — authenticated full service and system inventory (every response carries X-Request-ID).

Native macOS Menu Bar App (ServerHub.app)

Build and install into /Applications or per-user ~/Applications (no sudo required):

mkdir -p "$HOME/Applications"
./macos/build_app.sh "$HOME/Applications/ServerHub.app"
open "$HOME/Applications/ServerHub.app"
  • Automatically follows macOS system language (简体中文 / English, overridable via SERVERHUB_LANGUAGE=zh-Hans or en).
  • Displays live health counts, problematic services at the top, grouped service links, one-click start/stop/restart actions, and maintenance tasks.
  • Settings → Panel inside the Web UI can inspect ServerHub.app, toggle login autostart, or restart the background panel service.

Documentation Index


Template Placeholders (templates/)

Built-in and remote templates never hardcode host-specific paths or addresses. ServerHub expands these variables automatically at install time:

Placeholder Resolves to
{{HOME}} Current user's home directory
{{SERVICES}} Managed services root (defaults to ~/Services)
{{HOST_IP}} Detected primary LAN IPv4 address (or configured settings.host_ip)
{{TZ}} Host IANA timezone from /etc/localtime (fallback UTC)
{{OCR_LANG}} Tesseract language list derived from macOS preferred languages (e.g. eng+chi_sim)
{{UI_LANGS}} Locale list for multi-language apps such as Stirling-PDF (e.g. en_GB,zh_CN)

Authoring note: Always quote YAML front-matter defaults beginning with {{ (for example default: "{{HOME}}/Music"). tests/test_template_metadata.py validates every shipped template in CI.


Development & Verification

Run from the repository root:

# Backend test suite (-t . isolates mutable state into a temp directory via tests/__init__.py)
.venv/bin/python -m unittest discover -s tests -t . -q

# Frontend unit/a11y/i18n/contrast tests, Knip dead-code check, and production build (<150 KiB entry gate)
npm --prefix web test
npm --prefix web run check:dead-code
npm --prefix web run build

# Static unused-code checks
.venv/bin/python -m pyflakes hub tests app.py menubar.py
.venv/bin/python -m vulture hub tests app.py menubar.py --min-confidence 100

Restarting whichever LaunchAgent label manages your checkout:

DOMAIN="gui/$(id -u)"
for label in local.serverhub.panel local.serverhub com.elvin.serverhub; do
  if launchctl print "$DOMAIN/$label" >/dev/null 2>&1; then
    launchctl kickstart -k "$DOMAIN/$label" && echo "restarted $label"
    break
  fi
done

About

A macOS home-server management panel built with FastAPI, Vue 3, and a native menu-bar app.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages