рабочий вариант, но скороть 10 МБит
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/example/remote-access-platform/backend/internal/modules/worker"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/authority"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/config"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/fabriccontrol"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/httpserver"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/logging"
|
||||
"github.com/example/remote-access-platform/backend/internal/platform/module"
|
||||
@@ -33,12 +34,13 @@ import (
|
||||
)
|
||||
|
||||
type App struct {
|
||||
cfg config.Config
|
||||
logger *slog.Logger
|
||||
httpServer *http.Server
|
||||
workers []backgroundRunner
|
||||
db closeFunc
|
||||
redis closeFunc
|
||||
cfg config.Config
|
||||
logger *slog.Logger
|
||||
httpServer *http.Server
|
||||
fabricControl *fabriccontrol.Server
|
||||
workers []backgroundRunner
|
||||
db closeFunc
|
||||
redis closeFunc
|
||||
}
|
||||
|
||||
type closeFunc func() error
|
||||
@@ -138,7 +140,11 @@ func NewApp(ctx context.Context) (*App, error) {
|
||||
cfg: cfg,
|
||||
logger: logger,
|
||||
httpServer: httpserver.New(cfg.HTTP, router),
|
||||
workers: []backgroundRunner{workerEvents.Run, leaseMonitor.Run},
|
||||
fabricControl: fabriccontrol.New(fabriccontrol.Config{
|
||||
Enabled: cfg.FabricControl.Enabled,
|
||||
ListenAddr: cfg.FabricControl.ListenAddr,
|
||||
}, router),
|
||||
workers: []backgroundRunner{workerEvents.Run, leaseMonitor.Run},
|
||||
db: func() error {
|
||||
db.Close()
|
||||
return nil
|
||||
@@ -167,6 +173,14 @@ func (a *App) Run(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
}
|
||||
if a.fabricControl != nil && a.cfg.FabricControl.Enabled {
|
||||
go func() {
|
||||
a.logger.Info("fabric control quic starting", "addr", a.cfg.FabricControl.ListenAddr, "service", a.cfg.App.Name)
|
||||
if err := a.fabricControl.ListenAndServe(ctx); err != nil {
|
||||
errCh <- err
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -184,6 +198,9 @@ func (a *App) Run(ctx context.Context) error {
|
||||
if err := a.httpServer.Shutdown(shutdownCtx); err != nil {
|
||||
return fmt.Errorf("shutdown http server: %w", err)
|
||||
}
|
||||
if a.fabricControl != nil {
|
||||
_ = a.fabricControl.Close()
|
||||
}
|
||||
|
||||
if err := a.redis(); err != nil {
|
||||
return fmt.Errorf("close redis: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user