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

..03-May-2022-

activation/H02-Jun-2020-487280

daemon/H02-Jun-2020-325188

dbus/H02-Jun-2020-3,4882,357

examples/activation/H02-Jun-2020-278148

fixtures/H03-May-2022-4430

import1/H02-Jun-2020-411299

internal/dlopen/H02-Jun-2020-14791

journal/H02-Jun-2020-348233

login1/H02-Jun-2020-429314

machine1/H02-Jun-2020-468351

scripts/H02-Jun-2020-134108

sdjournal/H02-Jun-2020-2,0071,177

unit/H02-Jun-2020-2,0101,506

util/H02-Jun-2020-371183

.gitignoreH A D02-Jun-202010 21

.travis.ymlH A D02-Jun-20201.4 KiB4538

CONTRIBUTING.mdH A D02-Jun-20202.6 KiB7855

DCOH A D02-Jun-20201.4 KiB3727

JenkinsfileH A D02-Jun-2020773 3832

LICENSEH A D02-Jun-202010 KiB192155

NOTICEH A D02-Jun-2020126 64

README.mdH A D02-Jun-20203 KiB7447

code-of-conduct.mdH A D02-Jun-20203 KiB6247

go.modH A D02-Jun-202091 63

go.sumH A D02-Jun-2020169 32

testH A D02-Jun-20201.9 KiB8853

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://img.shields.io/badge/godoc-reference-5272B4)](https://pkg.go.dev/mod/github.com/coreos/go-systemd/v22/?tab=packages)
5![minimum golang 1.12](https://img.shields.io/badge/golang-1.12%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).
28It can be used to inform systemd of service start-up completion, watchdog events, and other status changes.
29
30## D-Bus
31
32The `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.
33[API documentation][dbus-doc] is available online.
34
35[dbus-doc]: https://pkg.go.dev/github.com/coreos/go-systemd/v22/dbus?tab=doc
36
37### Debugging
38
39Create `/etc/dbus-1/system-local.conf` that looks like this:
40
41```
42<!DOCTYPE busconfig PUBLIC
43"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
44"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
45<busconfig>
46    <policy user="root">
47        <allow eavesdrop="true"/>
48        <allow eavesdrop="true" send_destination="*"/>
49    </policy>
50</busconfig>
51```
52
53## Journal
54
55### Writing to the Journal
56
57Using 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.
58
59### Reading from the Journal
60
61The `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.
62
63## logind
64
65The `login1` package provides functions to integrate with the [systemd logind API](http://www.freedesktop.org/wiki/Software/systemd/logind/).
66
67## machined
68
69The `machine1` package allows interaction with the [systemd machined D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/machined/).
70
71## Units
72
73The `unit` package provides various functions for working with [systemd unit files](http://www.freedesktop.org/software/systemd/man/systemd.unit.html).
74