logmower-shipper/main.go

35 lines
679 B
Go
Raw Normal View History

2022-11-09 14:00:44 +00:00
package main
import (
2022-11-09 18:13:50 +00:00
"context"
"errors"
"fmt"
"log"
"net/http"
"os"
2022-11-09 18:13:50 +00:00
"os/signal"
2022-11-09 16:07:28 +00:00
"git.k-space.ee/k-space/logmower-shipper/pkg/watcher"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
go func() {
metricsPort := 2112
log.Printf("serving /metrics on port %d", metricsPort)
http.Handle("/metrics", promhttp.Handler())
if err := http.ListenAndServe(fmt.Sprintf(":%d", metricsPort), nil); !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("serving /metrics: %e", err)
}
}()
2022-11-09 18:13:50 +00:00
ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
if err := watcher.App.RunContext(ctx, os.Args); err != nil {
log.Fatal(err)
}
}