62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gosvc"
|
|
"gosvc/httpserver"
|
|
"gosvc/logger"
|
|
)
|
|
|
|
var (
|
|
cfg = getViper()
|
|
)
|
|
|
|
func GetConfig() Configuration {
|
|
return cfg
|
|
}
|
|
|
|
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: 5000 * time.Millisecond,
|
|
},
|
|
},
|
|
}
|
|
|
|
gosvc.Config.HTTPServer.MaxRequestsPerSecond = 4000
|
|
gosvc.Config.HTTPServer.MaxPendingRequests = 15000
|
|
}
|