homeio
PublikFork dari doctor-io/homeio
system.md
System
Purpose
The system module exposes metrics, Docker info/stats, server info, updates, backups, power controls, disk management, thermal warnings, weather widgets, and status bar data.
Locations
- Server-side:
lib/server/modules/system/, plus Docker/network modules for some data - Client-side:
modules/system/, settings sections undermodules/settings/ - Routes:
app/api/v1/system/,app/api/v1/docker/,app/api/v1/logs
Key Files
| File | Role |
|---|---|
lib/server/modules/system/service.ts | Metrics snapshot collection |
lib/server/modules/system/info-service.ts | Server info |
lib/server/modules/system/update-service.ts | Update status/apply |
lib/server/modules/system/backup-service.ts | Backup settings/list/run |
lib/server/modules/system/power-service.ts | Shutdown/reboot/factory reset |
lib/server/modules/system/disk-service.ts | Disk and partition operations |
modules/system/hooks/useSystemSse.ts | Metrics SSE client |
modules/system/components/monitor.tsx | System monitor UI |
modules/system/components/disk-manager.tsx | Disk manager UI |
modules/settings/components/panel/sections/server-info-section.tsx | Server info settings view |
Public API
getSystemMetricsSnapshot()getSystemUpdateStatus(),scheduleSystemUpdate()getSystemBackupsSnapshot(),runSystemBackupNow()scheduleSystemReboot(),scheduleSystemShutdown(),scheduleFactoryReset()getServerInfo()listDisks(),formatPartition(),mountPartition(),unmountPartition(),createPartition(),deletePartition(),wipeDisk()- Client hooks:
useSystemMetrics(),useSystemSse(),useDockerInfo(),useDockerStats(),useDisks(),useServerInfo()
Contracts
lib/shared/contracts/system.tslib/shared/contracts/disks.tslib/shared/contracts/server-info.tslib/shared/contracts/weather.ts
Database Tables
settingsfor appearance/system settings stored as JSON- Backup metadata is file-backed through the backup service, not a dedicated table in
schema.ts.
API Routes Owned
GET /api/v1/system/metricsGET /api/v1/system/streamGET /api/v1/system/infoGET/PUT /api/v1/system/preferencesGET/PUT /api/v1/system/securityGET /api/v1/system/updatesPOST /api/v1/system/updates/checkPOST /api/v1/system/updates/applyGET/POST/PUT /api/v1/system/backups*GET/POST /api/v1/system/power/*GET/POST /api/v1/system/disks*GET /api/v1/logs
Known Issues
app/api/v1/system/stream/route.tsauthenticates before opening the SSE stream.- Some metrics cache TTL constants are hardcoded in
lib/server/modules/system/service.ts. - Server info reads Linux host files and command output where available; fields can be null on unsupported hosts or containers.
modules/system/components/disk-manager.tsxis over 500 lines.- Power and disk routes are high-risk because they perform destructive host actions.
How To Extend
To add a system setting:
- Add contract fields in
lib/shared/contracts/system.ts. - Add persistence/default logic in
lib/server/modules/system/preferences-service.tsor the relevant service. - Add or update a route under
app/api/v1/system/. - Add request helpers in
modules/settings/hooks/backend/api.ts. - Add controller state in
modules/settings/components/panel/controllers.ts. - Add UI in the relevant settings section.
- Add tests for service, route, and save-policy helpers.