Skip to content

Commit

Permalink
Add systemd-notify support
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Oct 16, 2024
1 parent 61a9f20 commit 419996e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
14 changes: 11 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{ buildGoModule, ... }:
{ lib, buildGoModule }:
buildGoModule {
pname = "ipwatch";
version = "0.2.3";
src = ./.;
vendorHash = "sha256-VG1ZVwO78KUqyQpQw8hbjJm6AxvudoiNQbjYevd+qj8=";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./go.mod
./go.sum
./cmd
./ipwatch
];
};
vendorHash = "sha256-SG/XqEXKTqmWbfe4H9+yVDp4YKicm2fP+tVV5bCtIpk=";
ldflags = [
"-s"
"-w"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
toolchain go1.21.3

require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/mdlayher/netlink v1.7.2
golang.org/x/sys v0.26.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
Expand Down
3 changes: 3 additions & 0 deletions ipwatch/ipwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"
"unsafe"

systemdDaemon "github.com/coreos/go-systemd/daemon"
"github.com/mdlayher/netlink"
"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -456,6 +457,8 @@ func (w *Watcher) Watch(cfg WatchConfig) error {
)
}

systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyReady)

w.log.Println("Opening netlink socket")
conn, err := netlink.Dial(unix.NETLINK_ROUTE, &netlink.Config{
Groups: unix.RTMGRP_IPV4_IFADDR | unix.RTMGRP_IPV6_IFADDR,
Expand Down

0 comments on commit 419996e

Please sign in to comment.