Skip to content

Commit

Permalink
lib/sd-activation: wrap coreos/go-systemd
Browse files Browse the repository at this point in the history
It fails to build on plan9, which is part of the rclone CI matrix, and
the PR fixing it upstream doesn't seem to be getting traction.

Stub it on our side, we can still remove this once it gets merged.
  • Loading branch information
flokli committed May 13, 2024
1 parent 0529828 commit 0096111
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/serve/sftp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"path/filepath"
"strings"

sdActivation "github.com/coreos/go-systemd/v22/activation"
"github.com/rclone/rclone/cmd/serve/proxy"
"github.com/rclone/rclone/cmd/serve/proxy/proxyflags"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/lib/env"
"github.com/rclone/rclone/lib/file"
sdActivation "github.com/rclone/rclone/lib/sd-activation"
"github.com/rclone/rclone/vfs"
"github.com/rclone/rclone/vfs/vfsflags"
"golang.org/x/crypto/ssh"
Expand Down
2 changes: 1 addition & 1 deletion lib/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"sync"
"time"

sdActivation "github.com/coreos/go-systemd/v22/activation"
"github.com/go-chi/chi/v5"
"github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/lib/atexit"
sdActivation "github.com/rclone/rclone/lib/sd-activation"
"github.com/spf13/pflag"
)

Expand Down
25 changes: 25 additions & 0 deletions lib/sd-activation/sd_activation_stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Package sd_activate provides support for systemd socket activation,
// wrapping the coreos/go-systemd package.
// This wraps the underlying go-systemd binary, as it fails to build on plan9
// https://github.com/coreos/go-systemd/pull/440

//go:build windows || plan9
// +build windows plan9

package sd_activate

import (
"net"
)

// ListenersWithNames maps a listener name to a set of net.Listener instances.
// This wraps the underlying go-systemd binary, as it fails to build on plan9
// https://github.com/coreos/go-systemd/pull/440
func ListenersWithNames() (map[string][]net.Listener, error) {
return make(map[string][]net.Listener), nil
}

// Listeners returns a slice containing a net.Listener for each matching socket type passed to this process.
func Listeners() ([]net.Listener, error) {
return nil, nil
}
24 changes: 24 additions & 0 deletions lib/sd-activation/sd_activation_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package sd_activate provides support for systemd socket activation,
// wrapping the coreos/go-systemd package.
// This wraps the underlying go-systemd binary, as it fails to build on plan9
// https://github.com/coreos/go-systemd/pull/440

//go:build !windows && !plan9
// +build !windows,!plan9

package sd_activate

Check failure on line 9 in lib/sd-activation/sd_activation_unix.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: should have a package comment (revive)

import (
sdActivation "github.com/coreos/go-systemd/v22/activation"
"net"
)

// ListenersWithNames maps a listener name to a set of net.Listener instances.
func ListenersWithNames() (map[string][]net.Listener, error) {
return sdActivation.ListenersWithNames()
}

// ….

Check failure on line 21 in lib/sd-activation/sd_activation_unix.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function Listeners should be of the form "Listeners ..." (revive)
func Listeners() ([]net.Listener, error) {
return sdActivation.Listeners()
}

0 comments on commit 0096111

Please sign in to comment.