-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
63 lines (49 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"flag"
"fmt"
"os"
"github.com/coreos/go-systemd/daemon"
"github.com/labstack/echo-contrib/prometheus"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
prom "github.com/prometheus/client_golang/prometheus"
)
const (
appname = "typidor_exporter"
)
var (
version string
iteration string
commit string
env string
appversion = appname + " [" + version + "] " + commit + " on " + iteration + " @ " + env
listen string
ver bool
)
func init() {
flag.StringVar(&listen, "bind", ":9824", "Bind the HTTP server")
flag.BoolVar(&ver, "v", false, "Print version")
flag.Parse()
}
func main() {
if ver {
fmt.Println(appversion)
os.Exit(0)
}
metric := prom.NewGauge(
prom.GaugeOpts{
Namespace: "typidor",
Name: "status",
Help: "TY PIDOR status",
})
prom.MustRegister(metric)
metric.Set(1)
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
p := prometheus.NewPrometheus("echo", nil)
p.Use(e)
daemon.SdNotify(false, "READY=1")
e.Logger.Fatal(e.Start(listen))
}