all repos — honk @ 404bface8187a09381a92ad2b1ec7342a479e874

my fork of honk

support fastcgi. based on diff from timkuijsten
Ted Unangst tedu@tedunangst.com
Sun, 24 Sep 2023 22:36:13 -0400
commit

404bface8187a09381a92ad2b1ec7342a479e874

parent

069224ad431d5d7a9210bd7bf1893dac9b2eda69

4 files changed, 17 insertions(+), 0 deletions(-)

jump to
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

### next ++ FastCGI listening. + + Finally fix slow public queries. ### 1.1.1 Required Refinement
M docs/honk.8docs/honk.8

@@ -38,6 +38,8 @@ Make sure to pass the Host header, if necessary (as for nginx).

.Bd -literal -offset indent proxy_set_header Host $http_host; .Ed +.Pp +FastCGI can be used by prefixing the listen address with "fcgi:". .Ss Build Building .Nm
M util.goutil.go

@@ -431,6 +431,10 @@ err := getconfig("listenaddr", &listenAddr)

if err != nil { return nil, err } + if strings.HasPrefix(listenAddr, "fcgi:") { + listenAddr = listenAddr[5:] + usefcgi = true + } if listenAddr == "" { return nil, fmt.Errorf("must have listenaddr") }
M web.goweb.go

@@ -25,6 +25,7 @@ "io"

notrand "math/rand" "mime/multipart" "net/http" + "net/http/fcgi" "net/url" "os" "os/signal"

@@ -2754,6 +2755,8 @@

return fmt.Sprintf("?v=%.8x", hasher.Sum(nil)) } +var usefcgi bool + func serve() { db := opendatabase() login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode, SameSiteStrict: !develMode})

@@ -2892,6 +2895,12 @@ loggedin.HandleFunc("/q", showsearch)

loggedin.HandleFunc("/hydra", webhydra) loggedin.HandleFunc("/emus", showemus) loggedin.Handle("/submithonker", login.CSRFWrap("submithonker", http.HandlerFunc(websubmithonker))) + + if usefcgi { + err = fcgi.Serve(listener, mux) + } else { + err = http.Serve(listener, mux) + } err = http.Serve(listener, mux) if err != nil {