cc-backend/tools/archive-manager/main.go

41 lines
1.3 KiB
Go
Raw Normal View History

2022-09-06 09:32:25 +02:00
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package main
2023-03-31 11:25:12 +02:00
import (
"encoding/json"
"flag"
"fmt"
"github.com/ClusterCockpit/cc-backend/internal/config"
"github.com/ClusterCockpit/cc-backend/pkg/archive"
2023-04-12 12:27:15 +02:00
"github.com/ClusterCockpit/cc-backend/pkg/log"
2023-03-31 11:25:12 +02:00
)
2022-09-06 09:32:25 +02:00
func main() {
2023-04-12 12:27:15 +02:00
var srcPath, flagConfigFile, flagLogLevel string
var flagLogDateTime bool
2023-03-31 11:25:12 +02:00
flag.StringVar(&srcPath, "s", "./var/job-archive", "Specify the source job archive path. Default is ./var/job-archive")
2023-04-12 12:27:15 +02:00
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
flag.StringVar(&flagLogLevel, "loglevel", "warn", "Sets the logging level: `[debug,info,warn (default),err,fatal,crit]`")
2023-03-31 11:25:12 +02:00
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
flag.Parse()
archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", srcPath)
2023-04-12 12:27:15 +02:00
log.Init(flagLogLevel, flagLogDateTime)
2023-03-31 11:25:12 +02:00
config.Init(flagConfigFile)
config.Keys.Validate = true
2023-03-31 11:25:12 +02:00
2023-04-11 16:26:09 +02:00
if err := archive.Init(json.RawMessage(archiveCfg), false); err != nil {
2023-03-31 11:25:12 +02:00
log.Fatal(err)
}
ar := archive.GetHandle()
2022-09-06 09:32:25 +02:00
for job := range ar.Iter(true) {
log.Printf("Validate %s - %d\n", job.Meta.Cluster, job.Meta.JobID)
2023-03-31 11:25:12 +02:00
}
2022-09-06 09:32:25 +02:00
}