...

Text file src/github.com/coreos/go-systemd/v22/README.md

Documentation: github.com/coreos/go-systemd/v22

     1# go-systemd
     2
     3[![godoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://pkg.go.dev/mod/github.com/coreos/go-systemd/v22/?tab=packages)
     4![minimum golang 1.12](https://img.shields.io/badge/golang-1.12%2B-orange.svg)
     5
     6
     7Go bindings to systemd. The project has several packages:
     8
     9- `activation` - for writing and using socket activation from Go
    10- `daemon` - for notifying systemd of service status changes
    11- `dbus` - for starting/stopping/inspecting running services and units
    12- `journal` - for writing to systemd's logging service, journald
    13- `sdjournal` - for reading from journald by wrapping its C API
    14- `login1` - for integration with the systemd logind API
    15- `machine1` - for registering machines/containers with systemd
    16- `unit` - for (de)serialization and comparison of unit files
    17
    18## Socket Activation
    19
    20An example HTTP server using socket activation can be quickly set up by following this README on a Linux machine running systemd:
    21
    22https://github.com/coreos/go-systemd/tree/main/examples/activation/httpserver
    23
    24## systemd Service Notification
    25
    26The `daemon` package is an implementation of the [sd_notify protocol](https://www.freedesktop.org/software/systemd/man/sd_notify.html#Description).
    27It can be used to inform systemd of service start-up completion, watchdog events, and other status changes.
    28
    29## D-Bus
    30
    31The `dbus` package connects to the [systemd D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/dbus/) and lets you start, stop and introspect systemd units.
    32[API documentation][dbus-doc] is available online.
    33
    34[dbus-doc]: https://pkg.go.dev/github.com/coreos/go-systemd/v22/dbus?tab=doc
    35
    36### Debugging
    37
    38Create `/etc/dbus-1/system-local.conf` that looks like this:
    39
    40```
    41<!DOCTYPE busconfig PUBLIC
    42"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
    43"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
    44<busconfig>
    45    <policy user="root">
    46        <allow eavesdrop="true"/>
    47        <allow eavesdrop="true" send_destination="*"/>
    48    </policy>
    49</busconfig>
    50```
    51
    52## Journal
    53
    54### Writing to the Journal
    55
    56Using the pure-Go `journal` package you can submit journal entries directly to systemd's journal, taking advantage of features like indexed key/value pairs for each log entry.
    57
    58### Reading from the Journal
    59
    60The `sdjournal` package provides read access to the journal by wrapping around journald's native C API; consequently it requires cgo and the journal headers to be available.
    61
    62## logind
    63
    64The `login1` package provides functions to integrate with the [systemd logind API](http://www.freedesktop.org/wiki/Software/systemd/logind/).
    65
    66## machined
    67
    68The `machine1` package allows interaction with the [systemd machined D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/machined/).
    69
    70## Units
    71
    72The `unit` package provides various functions for working with [systemd unit files](http://www.freedesktop.org/software/systemd/man/systemd.unit.html).

View as plain text