Add anyhttp support #17
4
go.mod
4
go.mod
@ -3,10 +3,8 @@ module go.balki.me/collage-maker
|
|||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
go.balki.me/anyhttp v0.2.0
|
go.balki.me/anyhttp v0.3.0
|
||||||
go.oneofone.dev/resize v1.0.1
|
go.oneofone.dev/resize v1.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/image v0.1.0 // indirect
|
require golang.org/x/image v0.1.0 // indirect
|
||||||
|
|
||||||
replace go.balki.me/anyhttp => ../anyhttp
|
|
||||||
|
2
go.sum
2
go.sum
@ -1,4 +1,6 @@
|
|||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
go.balki.me/anyhttp v0.3.0 h1:WtBQ0rnkg567sX/O4ij/+qBbdCIUt5VURSe718sITBY=
|
||||||
|
go.balki.me/anyhttp v0.3.0/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s=
|
||||||
go.oneofone.dev/resize v1.0.1 h1:HjpVar/4pxMGrjO44ThaMX1Q5UOBw0KxzbxxRDZPQuA=
|
go.oneofone.dev/resize v1.0.1 h1:HjpVar/4pxMGrjO44ThaMX1Q5UOBw0KxzbxxRDZPQuA=
|
||||||
go.oneofone.dev/resize v1.0.1/go.mod h1:zGFmn7q4EUZVlnDmxqf+b0mWpxsTt0MH2yx6ng8tpq0=
|
go.oneofone.dev/resize v1.0.1/go.mod h1:zGFmn7q4EUZVlnDmxqf+b0mWpxsTt0MH2yx6ng8tpq0=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
8
main.go
8
main.go
@ -96,13 +96,13 @@ func main() {
|
|||||||
slog.Error("Failed to write collageFile", "error", err)
|
slog.Error("Failed to write collageFile", "error", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
addrType, server, err := anyhttp.ListenAndServeHTTP(listenAddr, idle.WrapHandler(nil))
|
addrType, server, done, err := anyhttp.Serve(listenAddr, idle.WrapHandler(nil))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("anyhttp ListenAndServeHTTP failed", "error", err)
|
slog.Error("anyhttp Serve failed", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if addrType == anyhttp.SystemdFD {
|
if addrType == anyhttp.SystemdFD {
|
||||||
if err := idle.Wait(1 * time.Minute); err != nil {
|
if err := idle.Wait(30 * time.Minute); err != nil {
|
||||||
slog.Error("Failed to wait for idler", "error", err)
|
slog.Error("Failed to wait for idler", "error", err)
|
||||||
}
|
}
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Minute) // Don't want any stuck connections
|
ctx, _ := context.WithTimeout(context.Background(), 1*time.Minute) // Don't want any stuck connections
|
||||||
@ -110,7 +110,7 @@ func main() {
|
|||||||
slog.Error("http server Shutdown failed", "error", err)
|
slog.Error("http server Shutdown failed", "error", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
select {}
|
<-done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user