From 2f586a29a068c0481737f298114b01bf6e8a64a5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 4 Oct 2021 17:15:49 +0300 Subject: [PATCH 1/1] Configuration spewing --- cmd/godlighty/main.go | 10 ++++++++++ doc/index.texi | 8 +++++++- go.mod | 1 + go.sum | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/godlighty/main.go b/cmd/godlighty/main.go index 6c71145..4198753 100644 --- a/cmd/godlighty/main.go +++ b/cmd/godlighty/main.go @@ -31,6 +31,7 @@ import ( "syscall" "time" + "github.com/davecgh/go-spew/spew" "golang.org/x/net/netutil" "go.stargrave.org/godlighty" @@ -91,6 +92,15 @@ func main() { } } + info := make(chan os.Signal) + signal.Notify(info, syscall.SIGINFO) + go func() { + for { + <-info + spew.Fdump(os.Stdout, godlighty.Hosts) + } + }() + srv := http.Server{Handler: godlighty.MainHandler} go func() { <-shutdown diff --git a/doc/index.texi b/doc/index.texi index 5be4234..41a3fd5 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -51,7 +51,13 @@ Can drop (UID, GID, groups) privileges. @end itemize -Basically all configuration is done directly inside source code. +Basically all configuration is done directly inside source code. You +have to recompile it every time configuration changes. Is it a problem? +I doubt, because Go is very fast. But it produces huge statically linked +executables, you say! Use @command{bsdiff}/@command{bspatch}! + +Send @code{SIGINFO} signal to get current daemon's configuration. + Initially @command{godlighty} has basic static files handlers (with compression, HTTP preconditions are enabled of course). In the example below there are nearly all default functions. diff --git a/go.mod b/go.mod index 0a306c8..5150035 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module go.stargrave.org/godlighty go 1.17 require ( + github.com/davecgh/go-spew v1.1.1 github.com/dustin/go-humanize v1.0.0 github.com/klauspost/compress v1.13.6 golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 diff --git a/go.sum b/go.sum index 514e0de..03c3f62 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -- 2.44.0