https://github.com/pires/go-systemdmanager
A Go library for managing systemd units via D-Bus API.
https://github.com/pires/go-systemdmanager
Last synced: 3 months ago
JSON representation
A Go library for managing systemd units via D-Bus API.
- Host: GitHub
- URL: https://github.com/pires/go-systemdmanager
- Owner: pires
- License: apache-2.0
- Created: 2025-09-01T10:23:32.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-09-08T22:33:31.000Z (4 months ago)
- Last Synced: 2025-09-28T00:57:09.455Z (3 months ago)
- Language: Go
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-systemdmanager
A Go library for managing systemd units via D-Bus API with OpenTelemetry instrumentation.
## Overview
This library provides a clean interface for controlling systemd units through D-Bus, supporting operations like start, stop, restart, uptime monitoring, and real-time status watching. It's designed with observability in mind, featuring comprehensive OpenTelemetry tracing and metrics.
## Features
- **Unit Lifecycle Management**: Start, stop, and restart systemd units
- **Status Monitoring**: Watch unit status changes in real-time
- **Uptime Tracking**: Retrieve unit uptime information
- **Observability**: Built-in OpenTelemetry instrumentation for tracing and metrics
- **Thread Safety**: Concurrent-safe operations with proper locking
## Usage
```go
import "github.com/pires/go-systemdmanager"
// Create a new manager
mgr, err := systemdmanager.New(ctx)
if err != nil {
log.Fatal(err)
}
// Start a unit
err = mgr.Start(ctx, "my-service.service")
// Watch for status changes
updatesChan := make(chan *dbus.UnitStatus)
go mgr.Watch(ctx, "my-service.service", updatesChan)
// Get uptime
uptime, err := mgr.Uptime(ctx, "my-service.service")
```
## Requirements
- Go 1.24+
- Linux with systemd
- D-Bus access
## Credits
This project evolved from:
- [virtual-kubelet/systemk](https://github.com/virtual-kubelet/systemk) - Virtual Kubelet systemd provider
- [firedancer-io/mirasol](https://github.com/firedancer-io/mirasol) - Solana RPC watchdog