Fixed a few issues:

- Incorrect name being shown on dashboard "Proxies page"
- Apps being shown when homepage.show is false
- Load balanced routes are shown on homepage instead of the load balancer
- Route with idlewatcher will now be removed on container destroy
- Idlewatcher panic
- Performance improvement
- Idlewatcher infinitely loading
- Reload stucked / not working properly
- Streams stuck on shutdown / reload
- etc...
Added:
- support idlewatcher for loadbalanced routes
- partial implementation for stream type idlewatcher
Issues:
- graceful shutdown
This commit is contained in:
yusing
2024-10-18 16:47:01 +08:00
parent c0c61709ca
commit 53557e38b6
69 changed files with 2368 additions and 1654 deletions

View File

@@ -1,6 +1,7 @@
package server
import (
"context"
"crypto/tls"
"errors"
"log"
@@ -9,8 +10,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/yusing/go-proxy/internal/autocert"
"github.com/yusing/go-proxy/internal/common"
"golang.org/x/net/context"
"github.com/yusing/go-proxy/internal/task"
)
type Server struct {
@@ -21,7 +21,8 @@ type Server struct {
httpStarted bool
httpsStarted bool
startTime time.Time
task common.Task
task task.Task
}
type Options struct {
@@ -84,7 +85,7 @@ func NewServer(opt Options) (s *Server) {
CertProvider: opt.CertProvider,
http: httpSer,
https: httpsSer,
task: common.GlobalTask(opt.Name + " server"),
task: task.GlobalTask(opt.Name + " server"),
}
}
@@ -115,11 +116,7 @@ func (s *Server) Start() {
}()
}
go func() {
<-s.task.Context().Done()
s.stop()
s.task.Finished()
}()
s.task.OnComplete("stop server", s.stop)
}
func (s *Server) stop() {
@@ -127,16 +124,13 @@ func (s *Server) stop() {
return
}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
if s.http != nil && s.httpStarted {
s.handleErr("http", s.http.Shutdown(ctx))
s.handleErr("http", s.http.Shutdown(s.task.Context()))
s.httpStarted = false
}
if s.https != nil && s.httpsStarted {
s.handleErr("https", s.https.Shutdown(ctx))
s.handleErr("https", s.https.Shutdown(s.task.Context()))
s.httpsStarted = false
}
}
@@ -147,7 +141,7 @@ func (s *Server) Uptime() time.Duration {
func (s *Server) handleErr(scheme string, err error) {
switch {
case err == nil, errors.Is(err, http.ErrServerClosed):
case err == nil, errors.Is(err, http.ErrServerClosed), errors.Is(err, context.Canceled):
return
default:
logrus.Fatalf("%s server %s error: %s", scheme, s.Name, err)