How ogarcia/sysdweb works
1. What this repo is
- sysdweb is a small Python application that exposes systemd service control through both a web UI and a REST API.
- It is intended to run locally or on a host where it can talk to the systemd daemon over its D-Bus interface.
2. Top-level runtime shape
- run.py is the likely command-line entrypoint, while sysdweb/main.py appears to hold the main startup flow.
- The app listens on a configurable host/port, defaulting to 127.0.0.1:10088, so it behaves like a self-contained local admin service rather than a distributed backend.
3. Configuration subsystem
- sysdweb/config.py is the boundary for reading runtime settings and the service registry.
- sysdweb.conf defines named service sections; each section maps a human-friendly title to a systemd unit name, and those section keys become the service IDs used in API paths.
4. HTTP server layer
- sysdweb/server.py is the request-routing layer that serves both HTML pages and API endpoints.
- The API follows a fixed pattern: /api/v1/<service>/<action> with optional journal line limits, and the server is responsible for translating requests into service operations and serializing responses.
5. systemd integration layer
- sysdweb/systemd.py is the core integration boundary to the host systemd environment.
- It is where start/stop/restart/reload/status/journal operations are executed, and the README indicates it relies on system D-Bus communication and systemd development libraries.
6. Data flow for control actions
- A request comes in through the HTTP server, the target service key is resolved from config, then the systemd layer executes the requested action.
- For control actions, the response is simple and machine-oriented: OK/Fail for mutating operations, and state strings such as active, inactive, failed, or not-found for status.
7. Journal retrieval path
- The journal action is a separate read path that returns tail lines from the service’s logs, with a default of 100 lines and optional override in the URL.
- This means the app is not only a service controller, but also a lightweight service-log viewer for systemd units.
8. Web UI layer
- sysdweb/templates/views/index.tpl and journal.tpl define the HTML views for the browser interface.
- The browser UI is complemented by sysdweb/templates/static/js/sysdweb.js and css/sysdweb.css, implying client-side interactions for triggering actions and refreshing service/journal views without manual API use.
9. Static asset boundary
- The templates/static tree contains the front-end assets only; the backend remains responsible for all actual systemd interaction.
- This keeps the presentation layer thin: it renders views and calls the same server endpoints that external clients use.
10. Deployment and operations
- systemd/sysdweb-system.service and systemd/sysdweb-user.service provide native systemd unit files for running sysdweb either as a system service or per-user service.
- This matches the app’s local-admin nature: it is itself typically launched and managed by systemd, and then manages other systemd units.
11. Packaging and distribution
- pyproject.toml plus .github/workflows/python-publish.yml indicate the project is packaged and published as a Python distribution.
- The repository is structured for installation from source or PyPI, with CI automation focused on release publication.
12. Architectural summary
- The key boundary is: HTTP/UI layer on one side, systemd D-Bus control on the other.
- The config file connects the two by defining which named services are exposed, and the server exposes those services consistently through both browser pages and a stable REST API.
Main entry points: server.py server · main.py main · systemd.py systemd · index.tpl index view
Components 14
Runtime
Application startup and request handling
Core
Configuration and systemd control
- config · Loads runtime settings and service registry
sysdweb/config.py - sysdweb.conf · Named service definitions
sysdweb.conf - systemd · systemd D-Bus integration
sysdweb/systemd.py
UI
Browser views and static assets
- index view · Main service dashboard
sysdweb/templates/views/index.tpl - journal view · Service log page
sysdweb/templates/views/journal.tpl - sysdweb.js · Browser-side interactions
sysdweb/templates/static/js/sysdweb.js - sysdweb.css · UI styling
sysdweb/templates/static/css/sysdweb.css
Ops
Packaging and service units
- system service · System-wide service unit
systemd/sysdweb-system.service - user service · Per-user service unit
systemd/sysdweb-user.service - pyproject · Build and distribution config
pyproject.toml - publish workflow · Package publishing automation
.github/workflows/python-publish.yml
Connections 16
- run.py → main: starts · CLI entrypoint launches the app
- main → config: loads · Startup reads runtime configuration
- main → server: binds · Initializes the HTTP server
- config → sysdweb.conf: reads · Service registry comes from config file
- server → config: uses · Resolves configured service IDs
- server → systemd: controls · Routes actions to systemd operations
- server → index view: renders · Serves the main browser page
- server → journal view: renders · Serves the journal page
- index view → sysdweb.js: uses · UI interactions are driven by client script
- journal view → sysdweb.js: uses · Journal page reuses browser script
- index view → sysdweb.css: styles · Main view is styled by shared CSS
- journal view → sysdweb.css: styles · Journal view is styled by shared CSS
- sysdweb.js → server: calls · Browser actions hit the same endpoints
- systemd → system service: deployed by · System service packaging
- systemd → user service: deployed by · User service packaging
- pyproject → publish workflow: published by · Release automation packages the project