Files
EdgeAPI/internal/const/vars.go

37 lines
812 B
Go
Raw Normal View History

2024-05-17 18:27:26 +08:00
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
2021-06-02 18:13:48 +08:00
package teaconst
import (
"crypto/sha1"
"fmt"
2023-03-14 09:17:05 +08:00
"os"
"strings"
"time"
2024-07-27 14:15:25 +08:00
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
)
2021-06-02 18:13:48 +08:00
var (
IsPlus = false
2023-03-31 12:39:01 +08:00
Edition = ""
MaxNodes int32 = 0
NodeId int64 = 0
Debug = false
InstanceCode = fmt.Sprintf("%x", sha1.Sum([]byte("INSTANCE"+types.String(time.Now().UnixNano())+"@"+types.String(rands.Int64()))))
2023-03-14 09:17:05 +08:00
IsMain = checkMain()
2021-06-02 18:13:48 +08:00
)
2023-03-14 09:17:05 +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, "___")
}