mirror of
https://github.com/Finesssee/ProxyPilot.git
synced 2026-11-20 20:34:36 +00:00
feat(embedded): register SDK providers and configure logging
Register token store and config providers at startup, apply default auth-dir resolution, and configure log output from config.
This commit is contained in:
@@ -16,6 +16,9 @@ import (
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
|
||||
configaccess "github.com/router-for-me/CLIProxyAPI/v6/sdk/access/config"
|
||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -63,12 +66,18 @@ func (s *Server) Start(configPath, password string) error {
|
||||
return fmt.Errorf("failed to load config: %w", err)
|
||||
}
|
||||
|
||||
// Resolve auth-dir to apply default if empty
|
||||
if resolvedAuthDir, errResolve := util.ResolveAuthDir(cfg.AuthDir); errResolve == nil {
|
||||
cfg.AuthDir = resolvedAuthDir
|
||||
}
|
||||
|
||||
s.configPath = resolvedPath
|
||||
s.password = password
|
||||
s.port = cfg.Port
|
||||
|
||||
// Setup logging
|
||||
// Setup logging with config-driven output
|
||||
logging.SetupBaseLogger()
|
||||
logging.ConfigureLogOutput(cfg.LoggingToFile, cfg.LogsMaxTotalSizeMB)
|
||||
|
||||
// Create context with cancel
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -89,6 +98,10 @@ func (s *Server) Start(configPath, password string) error {
|
||||
}))
|
||||
}
|
||||
|
||||
// Register SDK providers
|
||||
sdkAuth.RegisterTokenStore(sdkAuth.NewFileTokenStore())
|
||||
configaccess.Register()
|
||||
|
||||
service, err := builder.Build()
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
Reference in New Issue
Block a user