• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

activation/H04-Nov-2019-

daemon/H04-Nov-2019-

dbus/H04-Nov-2019-

examples/activation/H04-Nov-2019-

fixtures/H03-May-2022-

import1/H04-Nov-2019-

internal/dlopen/H04-Nov-2019-

journal/H04-Nov-2019-

login1/H04-Nov-2019-

machine1/H04-Nov-2019-

scripts/H04-Nov-2019-

sdjournal/H04-Nov-2019-

unit/H04-Nov-2019-

util/H04-Nov-2019-

v22/H11-Nov-2019-

.travis.ymlH A D04-Nov-20191.5 KiB

CONTRIBUTING.mdH A D04-Nov-20192.6 KiB

DCOH A D04-Nov-20191.4 KiB

Gopkg.tomlH A D04-Nov-2019119

JenkinsfileH A D04-Nov-2019773

LICENSEH A D04-Nov-201910 KiB

NOTICEH A D04-Nov-2019126

README.mdH A D04-Nov-20192.9 KiB

code-of-conduct.mdH A D04-Nov-20193 KiB

testH A D04-Nov-20191.9 KiB

README.md

1# go-systemd
2
3[![Build Status](https://travis-ci.org/coreos/go-systemd.png?branch=master)](https://travis-ci.org/coreos/go-systemd)
4[![godoc](https://godoc.org/github.com/coreos/go-systemd?status.svg)](http://godoc.org/github.com/coreos/go-systemd)
5![minimum golang 1.10](https://img.shields.io/badge/golang-1.10%2B-orange.svg)
6
7
8Go bindings to systemd. The project has several packages:
9
10- `activation` - for writing and using socket activation from Go
11- `daemon` - for notifying systemd of service status changes
12- `dbus` - for starting/stopping/inspecting running services and units
13- `journal` - for writing to systemd's logging service, journald
14- `sdjournal` - for reading from journald by wrapping its C API
15- `login1` - for integration with the systemd logind API
16- `machine1` - for registering machines/containers with systemd
17- `unit` - for (de)serialization and comparison of unit files
18
19## Socket Activation
20
21An example HTTP server using socket activation can be quickly set up by following this README on a Linux machine running systemd:
22
23https://github.com/coreos/go-systemd/tree/master/examples/activation/httpserver
24
25## systemd Service Notification
26
27The `daemon` package is an implementation of the [sd_notify protocol](https://www.freedesktop.org/software/systemd/man/sd_notify.html#Description). It 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. The API docs are here:
32
33http://godoc.org/github.com/coreos/go-systemd/dbus
34
35### Debugging
36
37Create `/etc/dbus-1/system-local.conf` that looks like this:
38
39```
40<!DOCTYPE busconfig PUBLIC
41"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
42"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
43<busconfig>
44    <policy user="root">
45        <allow eavesdrop="true"/>
46        <allow eavesdrop="true" send_destination="*"/>
47    </policy>
48</busconfig>
49```
50
51## Journal
52
53### Writing to the Journal
54
55Using 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.
56
57### Reading from the Journal
58
59The `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.
60
61## logind
62
63The `login1` package provides functions to integrate with the [systemd logind API](http://www.freedesktop.org/wiki/Software/systemd/logind/).
64
65## machined
66
67The `machine1` package allows interaction with the [systemd machined D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/machined/).
68
69## Units
70
71The `unit` package provides various functions for working with [systemd unit files](http://www.freedesktop.org/software/systemd/man/systemd.unit.html).
72