优化节点分配逻辑,使用 edge id 固定轮换顺位;日志与 journal 集成;完善命令执行后的资源清理

This commit is contained in:
2025-08-19 11:09:58 +08:00
parent b6731f8442
commit 0c32337168
10 changed files with 75 additions and 31 deletions

16
main.go
View File

@@ -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 {