remote-challenge-sync-airbus: WIP

This commit is contained in:
nemunaire 2022-06-08 00:09:49 +02:00
commit 0831ea6088
3 changed files with 65 additions and 22 deletions

View file

@ -10,6 +10,7 @@ import (
"path/filepath"
"strconv"
"syscall"
"time"
"gopkg.in/fsnotify.v1"
)
@ -30,7 +31,7 @@ func main() {
flag.Parse()
api := AirbusAPI{
BaseURL: "https://portal.european-cybercup.lan/api/v1",
BaseURL: "https://portal.european-cybercup.lan/api",
}
if v, exists := os.LookupEnv("AIRBUS_BASEURL"); exists {
@ -46,6 +47,9 @@ func main() {
log.Fatal("AIRBUS_SESSIONID is invalid: ", err.Error())
}
}
if v, exists := os.LookupEnv("AIRBUS_SESSIONUUID"); exists {
api.SessionUUID = v
}
log.SetPrefix("[challenge-sync-airbus] ")
@ -79,7 +83,7 @@ func main() {
if !skipInitialSync {
// Iterate over teams scores
err = filepath.WalkDir(TeamsDir, w.WalkScore)
err = filepath.WalkDir(TeamsDir, w.WalkScoreSync)
if err != nil {
log.Printf("Something goes wrong during walking")
}
@ -112,7 +116,7 @@ func main() {
interrupt3 := make(chan os.Signal, 1)
signal.Notify(interrupt3, syscall.SIGUSR2)
c := time.NewTicker(5 * time.Second)
ticker := time.NewTicker(5 * time.Second)
watchedNotify := fsnotify.Create
@ -136,7 +140,7 @@ func main() {
case <-interrupt2:
log.Println("SIGUSR1 received, resynching all teams")
// Iterate over teams scores
err = filepath.WalkDir(TeamsDir, w.WalkScore)
err = filepath.WalkDir(TeamsDir, w.WalkScoreSync)
if err != nil {
log.Printf("Something goes wrong during walking")
}