mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-06 07:45:47 +08:00
优化代码
This commit is contained in:
@@ -282,14 +282,14 @@ func (this *APIStream) handleStatCache(message *pb.NodeStreamMessage) error {
|
||||
}
|
||||
|
||||
sizeFormat := ""
|
||||
if stat.Size < 1024 {
|
||||
if stat.Size < (1 << 10) {
|
||||
sizeFormat = strconv.FormatInt(stat.Size, 10) + " Bytes"
|
||||
} else if stat.Size < 1024*1024 {
|
||||
sizeFormat = fmt.Sprintf("%.2f KB", float64(stat.Size)/1024)
|
||||
} else if stat.Size < 1024*1024*1024 {
|
||||
sizeFormat = fmt.Sprintf("%.2f MB", float64(stat.Size)/1024/1024)
|
||||
} else if stat.Size < (1 << 20) {
|
||||
sizeFormat = fmt.Sprintf("%.2f KiB", float64(stat.Size)/(1<<10))
|
||||
} else if stat.Size < (1 << 30) {
|
||||
sizeFormat = fmt.Sprintf("%.2f MiB", float64(stat.Size)/(1<<20))
|
||||
} else {
|
||||
sizeFormat = fmt.Sprintf("%.2f GB", float64(stat.Size)/1024/1024/1024)
|
||||
sizeFormat = fmt.Sprintf("%.2f GiB", float64(stat.Size)/(1<<30))
|
||||
}
|
||||
this.replyOk(message.RequestId, "size:"+sizeFormat+", count:"+strconv.Itoa(stat.Count))
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
const (
|
||||
// AccessLogMaxRequestBodySize 访问日志存储的请求内容最大尺寸 TODO 此值应该可以在访问日志页设置
|
||||
AccessLogMaxRequestBodySize = 2 * 1024 * 1024
|
||||
AccessLogMaxRequestBodySize = 2 << 20
|
||||
)
|
||||
|
||||
// 日志
|
||||
|
||||
@@ -213,7 +213,7 @@ func (this *Node) Start() {
|
||||
events.Notify(events.EventLoaded)
|
||||
|
||||
// 设置rlimit
|
||||
_ = utils.SetRLimit(1024 * 1024)
|
||||
_ = utils.SetRLimit(1 << 20)
|
||||
|
||||
// 连接API
|
||||
goman.New(func() {
|
||||
|
||||
Reference in New Issue
Block a user