robotfs/config/config.go
2025-05-20 15:49:23 +08:00

59 lines
1.3 KiB
Go

package config
import (
"robotfs/utils"
"time"
"gosvc"
"gosvc/httpserver"
"gosvc/logger"
)
var (
cfg = utils.GetViper()
)
func SetupServiceConfig() {
gosvc.Config = gosvc.ServiceConfig{
Name: "robotfs",
Version: gosvc.Config.Version,
Runtime: gosvc.RuntimeConfig{
RootOnly: false,
},
Logger: gosvc.LoggerConfig{
Options: logger.Options{
TargetDirectory: cfg.GetString("robotfs.log_path"),
FilePrefix: "robotfs",
CycleFiles: 16,
MaxFileSize: 64 * 1024 * 1024,
},
},
Ticker: gosvc.TickerConfig{
Enable: false,
TickInterval: 1300 * time.Millisecond,
TickMinInterval: 300 * time.Millisecond,
TickOnStop: true,
},
Saver: gosvc.SaverConfig{
Enable: false,
SaveInterval: 60 * time.Second,
SaveMinInterval: 500 * time.Millisecond,
},
HTTPServer: gosvc.HTTPServerConfig{
Enable: true,
Options: httpserver.Options{
Address: cfg.GetString("robotfs.address"),
TLSEnabled: false,
CrossOriginEnabled: true,
MaxConcurrentStreams: 10000,
MaxTraces: 30 * 10000,
LogSlowRequest: true,
SlowRequestThreshold: 1000 * time.Millisecond,
},
},
}
gosvc.Config.HTTPServer.MaxRequestsPerSecond = 4000
gosvc.Config.HTTPServer.MaxPendingRequests = 15000
}