talira

go-systemd

Go bindings for systemd socket activation, sd_notify, journald, D-Bus and unit files

open sourceApache-2.0free

go-systemd is a set of Go packages for working with systemd: socket activation, service status notification through the sd_notify protocol, starting, stopping and inspecting units over systemd's D-Bus API, writing to journald in pure Go and reading it through journald's C API, logind and machined integration, and parsing and comparing unit files.

Problems it solves

  • tell systemd my Go service has finished starting up
  • use systemd socket activation in a Go HTTP server
  • write structured logs to journald from a Go program

Features

  • socket activation for Go servers
  • sd_notify service status and watchdog notifications
  • start, stop and inspect units over systemd's D-Bus API
  • write to journald in pure Go and read it through its C API
  • logind and machined integration, and unit file parsing

Limitations

  • Reading the journal (sdjournal) needs cgo and the journal headers1
  • Needs Go 1.24 or newer1