优化节点分配逻辑,使用 edge id 固定轮换顺位;日志与 journal 集成;完善命令执行后的资源清理
This commit is contained in:
16
main.go
16
main.go
@@ -6,11 +6,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"zzman/actions"
|
||||
"zzman/clients"
|
||||
"zzman/model"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
slogjournal "github.com/systemd/slog-journal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -29,8 +31,22 @@ func main() {
|
||||
slog.Error(fmt.Errorf("初始化变量失败:%w", err).Error())
|
||||
}
|
||||
|
||||
// 初始化日志
|
||||
handler, err := slogjournal.NewHandler(&slogjournal.Options{
|
||||
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
|
||||
a.Key = strings.ToUpper(a.Key)
|
||||
a.Key = strings.ReplaceAll(a.Key, "-", "_")
|
||||
return a
|
||||
},
|
||||
})
|
||||
slog.SetDefault(slog.New(handler))
|
||||
|
||||
// 初始化数据库和 Redis
|
||||
model.Init()
|
||||
defer model.Close()
|
||||
|
||||
clients.InitRedis()
|
||||
defer clients.CloseRedis()
|
||||
|
||||
// 执行命令
|
||||
if len(os.Args) < 2 {
|
||||
|
||||
Reference in New Issue
Block a user