improve check for offline rules (#1013)

* improve check for offline rules

* bug fixes

* update dependencies

* fix error wrap

* fix offline check

* improve readability
This commit is contained in:
UUBulb
2025-03-02 15:37:21 +08:00
committed by GitHub
parent 655d034f79
commit 5c8cc75523
13 changed files with 198 additions and 167 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/nezhahq/nezha/cmd/dashboard/controller/waf"
"github.com/nezhahq/nezha/cmd/dashboard/rpc"
"github.com/nezhahq/nezha/model"
"github.com/nezhahq/nezha/pkg/utils"
"github.com/nezhahq/nezha/proto"
"github.com/nezhahq/nezha/service/singleton"
)
@@ -154,6 +155,7 @@ func main() {
}
errChan := make(chan error, 2)
errHTTPS := errors.New("error from https server")
if err := graceful.Graceful(func() error {
log.Printf("NEZHA>> Dashboard::START ON %s:%d", singleton.Conf.ListenHost, singleton.Conf.ListenPort)
@@ -171,12 +173,16 @@ func main() {
log.Println("NEZHA>> Graceful::START")
singleton.RecordTransferHourlyUsage()
log.Println("NEZHA>> Graceful::END")
err := muxServerHTTPS.Shutdown(c)
return errors.Join(muxServerHTTP.Shutdown(c), err)
var err error
if muxServerHTTPS != nil {
err = muxServerHTTPS.Shutdown(c)
}
return errors.Join(muxServerHTTP.Shutdown(c), utils.IfOr(err != nil, utils.NewWrapError(errHTTPS, err), nil))
}); err != nil {
log.Printf("NEZHA>> ERROR: %v", err)
if errors.Unwrap(err) != nil {
log.Printf("NEZHA>> ERROR HTTPS: %v", err)
var wrapError *utils.WrapError
if errors.As(err, &wrapError) {
log.Printf("NEZHA>> ERROR HTTPS: %v", wrapError.Unwrap())
}
}