File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ require (
1717require (
1818 github.com/carlmjohnson/versioninfo v0.22.5
1919 github.com/coreos/go-systemd/v22 v22.6.0
20+ github.com/google/gops v0.3.28
2021)
2122
2223require (
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
3939github.com/google/go-cmp v0.4.0 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
4040github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI =
4141github.com/google/go-cmp v0.6.0 /go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY =
42+ github.com/google/gops v0.3.28 h1:2Xr57tqKAmQYRAfG12E+yLcoa2Y42UJo2lOrUFL9ark =
43+ github.com/google/gops v0.3.28 /go.mod h1:6f6+Nl8LcHrzJwi8+p0ii+vmBFSlB4f8cOOkTJ7sk4c =
4244github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms =
4345github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 /go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg =
4446github.com/holoplot/go-avahi v1.0.1 h1:XcqR2keL4qWRnlxHD5CAOdWpLFZJ+EOUK0vEuylfvvk =
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313 "github.com/coreos/go-systemd/v22/daemon"
1414 "github.com/docker/docker/client"
1515 "github.com/godbus/dbus/v5"
16+ "github.com/google/gops/agent"
1617 "github.com/holoplot/go-avahi"
1718 "github.com/kelseyhightower/envconfig"
1819 "ldddns.arnested.dk/internal/log"
2930//
3031//nolint:lll
3132type Config struct {
33+ Gops bool `default:"false" json:"Gops" split_words:"true"`
3234 HostnameLookup []string `default:"env:VIRTUAL_HOST,containerName" json:"HostnameLookup" split_words:"true"`
3335 IgnoreDockerComposeOneoff bool `default:"true" json:"IgnoreDockerComposeOneoff" split_words:"true"`
3436}
@@ -53,6 +55,8 @@ func main() {
5355 panic (fmt .Errorf ("could not read environment config: %w" , err ))
5456 }
5557
58+ gops (config .Gops )
59+
5660 docker , err := client .NewClientWithOpts (
5761 client .FromEnv ,
5862 client .WithAPIVersionNegotiation (),
@@ -132,3 +136,17 @@ func getVersion() string {
132136
133137 return version
134138}
139+
140+ // gops starts the gops agent if the config option is set.
141+ func gops (start bool ) {
142+ if ! start {
143+ return
144+ }
145+
146+ err := agent .Listen (agent.Options {
147+ ShutdownCleanup : true , // automatically closes on os.Interrupt
148+ })
149+ if err != nil {
150+ panic (fmt .Errorf ("could not start gops agent: %w" , err ))
151+ }
152+ }
You can’t perform that action at this time.
0 commit comments