2021-11-13 21:30:24 +08:00
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package teaconst
|
|
|
|
|
|
2022-08-09 22:59:37 +08:00
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
|
|
|
|
"os"
|
2023-03-13 21:49:41 +08:00
|
|
|
"strings"
|
2022-08-09 22:59:37 +08:00
|
|
|
)
|
2022-01-09 10:53:21 +08:00
|
|
|
|
2021-11-13 21:30:24 +08:00
|
|
|
var (
|
|
|
|
|
// 流量统计
|
|
|
|
|
|
|
|
|
|
InTrafficBytes = uint64(0)
|
|
|
|
|
OutTrafficBytes = uint64(0)
|
2021-11-16 16:11:05 +08:00
|
|
|
|
2021-12-02 11:30:47 +08:00
|
|
|
NodeId int64 = 0
|
|
|
|
|
NodeIdString = ""
|
2023-03-13 21:49:41 +08:00
|
|
|
IsMain = checkMain()
|
2022-01-09 10:53:21 +08:00
|
|
|
|
|
|
|
|
GlobalProductName = nodeconfigs.DefaultProductName
|
2022-03-13 19:27:38 +08:00
|
|
|
|
2022-03-14 11:47:34 +08:00
|
|
|
IsQuiting = false // 是否正在退出
|
|
|
|
|
EnableDBStat = false // 是否开启本地数据库统计
|
2021-11-13 21:30:24 +08:00
|
|
|
)
|
2023-03-13 21:49:41 +08:00
|
|
|
|
|
|
|
|
// 检查是否为主程序
|
|
|
|
|
func checkMain() bool {
|
|
|
|
|
if len(os.Args) == 1 ||
|
|
|
|
|
(len(os.Args) >= 2 && os.Args[1] == "pprof") {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
exe, _ := os.Executable()
|
|
|
|
|
return strings.HasSuffix(exe, ".test") ||
|
|
|
|
|
strings.HasSuffix(exe, ".test.exe") ||
|
|
|
|
|
strings.Contains(exe, "___")
|
|
|
|
|
}
|