Skip to content
Snippets Groups Projects
main.go 857 B
package main

import (
	"context"
	"flag"
	"os"
	"os/signal"
	"syscall"

	"go.science.ru.nl/cmd/repaird/repair"
	"go.science.ru.nl/log"
)

var (
	flagWrite    = flag.Bool("w", false, "write metrics to node exporter text dir")
	flagPromFile = flag.String("p", "/var/lib/prometheus/node-exporter/repaird.prom", "prom file path for writing repaird.prom")
	flagRepair   = flag.Bool("r", false, "when true also repair things, otherwise only detect")
)

func main() {
	flag.Parse()
	ctx, cancel := context.WithCancel(context.TODO())

	log.Infof("Starting main loop with %d repairers registered: %v", len(repair.R), repair.Names())

	if *flagWrite {
		log.Infof("Writing metrics into %s", *flagPromFile)
	}
	go Run(ctx)

	done := make(chan os.Signal, 1)
	signal.Notify(done, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
	select {
	case <-done:
		cancel()
	}
}