31 lines
627 B
Go
31 lines
627 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"lostak.dev/shelly-exporter/application"
|
|
)
|
|
|
|
func main() {
|
|
var configPath string
|
|
flag.StringVar(&configPath, "config", "config.yaml", "Path to the YAML configuration file.")
|
|
flag.Parse()
|
|
|
|
app, err := application.New(configPath)
|
|
if err != nil {
|
|
log.Fatalf("Cannot initialize Shelly exporter: %v", err)
|
|
}
|
|
|
|
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer stop()
|
|
|
|
if err := app.Run(ctx); err != nil {
|
|
log.Fatalf("Shelly exporter stopped unexpectedly: %v", err)
|
|
}
|
|
}
|