package main import ( "flag" "github.com/cyrilix/pod-cleaner/pkg/cleaner" "go.uber.org/zap" "github.com/prometheus/client_golang/prometheus/promhttp" "log" "net/http" ) func main() { var metricPath string var metricPort string var logfile string flag.StringVar(&metricPath, "metric-path", "/metrics", "Url path for metrics") flag.StringVar(&metricPort, "metric-port", ":9098", "Http port to expose metrics") flag.StringVar(&logfile, "log-file", "/var/syslog", "Log file to watch for orphan messages") logLevel := zap.LevelFlag("log", zap.InfoLevel, "log level") flag.Parse() config := zap.NewDevelopmentConfig() config.Level = zap.NewAtomicLevelAt(*logLevel) lgr, err := config.Build() if err != nil { log.Fatalf("unable to init logger: %v", err) } defer lgr.Sync() zap.ReplaceGlobals(lgr) c := cleaner.NewPodWatcher("log-file") defer c.Close() go c.Watch() http.Handle(metricPath, promhttp.Handler()) err = http.ListenAndServe(metricPort, nil) if err != nil { log.Panicf("unable to start prometheus listener: %v", err) } }