diff --git a/config.example.yaml b/config.example.yaml index 0938753d9..83c62bfac 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -39,6 +39,9 @@ api-keys: # Enable debug logging debug: false +# When true, disable high-overhead HTTP middleware features to reduce per-request memory usage under high concurrency. +commercial-mode: false + # Open OAuth URLs in incognito/private browser mode. # Useful when you want to login with a different account without logging out from your current session. # Default: false (but Kiro auth defaults to true for multi-account support) diff --git a/internal/api/server.go b/internal/api/server.go index d6f7e2349..ef4559617 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -209,13 +209,15 @@ func NewServer(cfg *config.Config, authManager *auth.Manager, accessManager *sdk // Resolve logs directory relative to the configuration file directory. var requestLogger logging.RequestLogger var toggle func(bool) - if optionState.requestLoggerFactory != nil { - requestLogger = optionState.requestLoggerFactory(cfg, configFilePath) - } - if requestLogger != nil { - engine.Use(middleware.RequestLoggingMiddleware(requestLogger)) - if setter, ok := requestLogger.(interface{ SetEnabled(bool) }); ok { - toggle = setter.SetEnabled + if !cfg.CommercialMode { + if optionState.requestLoggerFactory != nil { + requestLogger = optionState.requestLoggerFactory(cfg, configFilePath) + } + if requestLogger != nil { + engine.Use(middleware.RequestLoggingMiddleware(requestLogger)) + if setter, ok := requestLogger.(interface{ SetEnabled(bool) }); ok { + toggle = setter.SetEnabled + } } } diff --git a/internal/config/config.go b/internal/config/config.go index 4f50f494a..a23ad369e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -39,6 +39,9 @@ type Config struct { // Debug enables or disables debug-level logging and other debug features. Debug bool `yaml:"debug" json:"debug"` + // CommercialMode disables high-overhead HTTP middleware features to minimize per-request memory usage. + CommercialMode bool `yaml:"commercial-mode" json:"commercial-mode"` + // LoggingToFile controls whether application logs are written to rotating files or stdout. LoggingToFile bool `yaml:"logging-to-file" json:"logging-to-file"`