package main

import (
	"log"

	"golang.org/x/sync/errgroup"

	"git.jmbit.de/jmb/podterminal/pods"
	"git.jmbit.de/jmb/podterminal/utils"
	"git.jmbit.de/jmb/podterminal/web"
)

var (
	g errgroup.Group
)

func main() {
	readConfigFile()
	pods.ConnectSocket()

	// Start Webserver
	g.Go(web.Run)

	utils.DropPrivileges("podterminal")
	log.Println("Dropped Privileges")
	g.Go(pods.GarbageCollector)
	g.Go(pods.PullImage)

	// prevent main thread from dying
	if err := g.Wait(); err != nil {
		log.Fatal(err)
	}
}
