mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 03:02:07 +03:00
Pull request: all: opt log levels more
Updates #3929. Squashed commit of the following: commit 0d4aadeff1c4de1440795faf83eb072c46392ff3 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Dec 28 16:34:44 2021 +0300 all: opt log levels more
This commit is contained in:
parent
d2ce06e1ca
commit
380cff07f2
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome
|
|||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/AdguardTeam/dnsproxy v0.40.1
|
github.com/AdguardTeam/dnsproxy v0.40.2
|
||||||
github.com/AdguardTeam/golibs v0.10.3
|
github.com/AdguardTeam/golibs v0.10.3
|
||||||
github.com/AdguardTeam/urlfilter v0.15.1
|
github.com/AdguardTeam/urlfilter v0.15.1
|
||||||
github.com/NYTimes/gziphandler v1.1.1
|
github.com/NYTimes/gziphandler v1.1.1
|
||||||
|
4
go.sum
4
go.sum
@ -7,8 +7,8 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr
|
|||||||
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
|
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
|
||||||
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
|
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
|
||||||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
||||||
github.com/AdguardTeam/dnsproxy v0.40.1 h1:lYNi7VeCBhmdyf5xEUxfj84ikgiz5cjzocL9moiIRhk=
|
github.com/AdguardTeam/dnsproxy v0.40.2 h1:GG4StH+d4rB7YW3d20sdQjJG8URUeaIQicnEAsYJY7w=
|
||||||
github.com/AdguardTeam/dnsproxy v0.40.1/go.mod h1:PZ9l22h3Er+5mxFQB7oHZMTvx+aa9R6LbzA/ikXQlS0=
|
github.com/AdguardTeam/dnsproxy v0.40.2/go.mod h1:PZ9l22h3Er+5mxFQB7oHZMTvx+aa9R6LbzA/ikXQlS0=
|
||||||
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
||||||
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
||||||
github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY=
|
github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY=
|
||||||
|
@ -1056,8 +1056,6 @@ func (s *v4Server) Start() (err error) {
|
|||||||
go func() {
|
go func() {
|
||||||
if serr := s.srv.Serve(); errors.Is(serr, net.ErrClosed) {
|
if serr := s.srv.Serve(); errors.Is(serr, net.ErrClosed) {
|
||||||
log.Info("dhcpv4: server is closed")
|
log.Info("dhcpv4: server is closed")
|
||||||
|
|
||||||
return
|
|
||||||
} else if serr != nil {
|
} else if serr != nil {
|
||||||
log.Error("dhcpv4: srv.Serve: %s", serr)
|
log.Error("dhcpv4: srv.Serve: %s", serr)
|
||||||
}
|
}
|
||||||
|
@ -662,8 +662,11 @@ func (s *v6Server) Start() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err = s.srv.Serve()
|
if serr := s.srv.Serve(); errors.Is(serr, net.ErrClosed) {
|
||||||
log.Error("dhcpv6: srv.Serve: %s", err)
|
log.Info("dhcpv6: server is closed")
|
||||||
|
} else if serr != nil {
|
||||||
|
log.Error("dhcpv6: srv.Serve: %s", serr)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||||
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/AdguardTeam/golibs/netutil"
|
"github.com/AdguardTeam/golibs/netutil"
|
||||||
"github.com/NYTimes/gziphandler"
|
"github.com/NYTimes/gziphandler"
|
||||||
@ -175,35 +176,48 @@ func (web *Web) Start() {
|
|||||||
WriteTimeout: web.conf.WriteTimeout,
|
WriteTimeout: web.conf.WriteTimeout,
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
defer log.OnPanic("web: plain")
|
||||||
|
|
||||||
errs <- web.httpServer.ListenAndServe()
|
errs <- web.httpServer.ListenAndServe()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if web.conf.BetaBindPort != 0 {
|
web.startBetaServer(hostStr)
|
||||||
web.httpServerBeta = &http.Server{
|
|
||||||
ErrorLog: log.StdLog("web: plain", log.DEBUG),
|
|
||||||
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
|
|
||||||
Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
|
|
||||||
ReadTimeout: web.conf.ReadTimeout,
|
|
||||||
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
|
|
||||||
WriteTimeout: web.conf.WriteTimeout,
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
betaErr := web.httpServerBeta.ListenAndServe()
|
|
||||||
if betaErr != nil {
|
|
||||||
log.Error("starting beta http server: %s", betaErr)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
err := <-errs
|
err := <-errs
|
||||||
if err != http.ErrServerClosed {
|
if !errors.Is(err, http.ErrServerClosed) {
|
||||||
cleanupAlways()
|
cleanupAlways()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop
|
|
||||||
|
// We use ErrServerClosed as a sign that we need to rebind on a new
|
||||||
|
// address, so go back to the start of the loop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// startBetaServer starts the beta HTTP server if necessary.
|
||||||
|
func (web *Web) startBetaServer(hostStr string) {
|
||||||
|
if web.conf.BetaBindPort == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
web.httpServerBeta = &http.Server{
|
||||||
|
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
|
||||||
|
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
|
||||||
|
Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
|
||||||
|
ReadTimeout: web.conf.ReadTimeout,
|
||||||
|
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
|
||||||
|
WriteTimeout: web.conf.WriteTimeout,
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
defer log.OnPanic("web: plain: beta")
|
||||||
|
|
||||||
|
betaErr := web.httpServerBeta.ListenAndServe()
|
||||||
|
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
|
||||||
|
log.Error("starting beta http server: %s", betaErr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// Close gracefully shuts down the HTTP servers.
|
// Close gracefully shuts down the HTTP servers.
|
||||||
func (web *Web) Close(ctx context.Context) {
|
func (web *Web) Close(ctx context.Context) {
|
||||||
log.Info("stopping http server...")
|
log.Info("stopping http server...")
|
||||||
|
Loading…
Reference in New Issue
Block a user